Measurement of the high-energy electron and positron spectrum in the PAMELA experiment