Deep CCD photometry of stars in the globular cluster M3