Quantum-nondemolition measurement of small photon numbers and the preparation of number states.