Reversible Precounter for Photon Counting