Conditional preparation of states containing a definite number of photons