Migration of planetesimals from the feeding zone of the terrestrial planets, which was divided into seven regions depending on the distance to the Sun, was simulated. The influence of gravity of all planets was taken into account. In some cases, the embryos of the terrestrial planets rather than the planets themselves were considered; their masses were assumed to be 0.1 or 0.3 of the current masses of the planets. The arrays of orbital elements of migrated planetesimals were used to calculate the probabilities of their collisions with the planets, the Moon, or their embryos. Based on our calculations, we drew conclusions on the process of accumulation of the terrestrial planets. The embryos of the terrestrial planets, the masses of which did not exceed a tenth of the current planetary masses, accumulated planetesimals mainly from the vicinity of their orbits. When planetesimals fell onto the embryos of the terrestrial planets from the feeding zone of Jupiter and Saturn, these embryos had not yet acquired the current masses of the planets, and the material of this zone (including water and volatiles) could be accumulated in the inner layers of the terrestrial planets. The inner layers of each of the terrestrial planets were mainly formed from the material located in the vicinity of the orbit of a certain planet. The outer layers of the Earth and Venus could accumulate the same material for these two planets from different parts of the feeding zone of the terrestrial planets. The Earth and Venus could acquire more than half of their masses in 5 Myr. A relatively rapid growth of the bulk of the Martian mass can be explained by the formation of Mars embryo (the mass of which is several times less than that of Mars) due to contraction of a rarefied condensation.