Simple optical measurement of the overlap and fidelity of quantum states