Flux and energy spectrum of secondary electrons in the upper atmosphere