Measuring the photon distribution with ON/OFF photodetectors