Derivation of the Langevin equation from the principle of detailed balance