Solar modulation of the spectra of protons and helium nuclei in the PAMELA experiment