Positrons and electrons in primary cosmic rays as measured in the PAMELA experiment