Application of random walk theory to the first-order Fermi acceleration in shock waves