We consider a spin Hamiltonian describing d-d exchange interactions between localized spins d of a finite antiferromagnet as well as p-d interactions between a conducting hole (p) and localized spins. The spin Hamiltonian is solved numerically with use of Lanczos method of diagonalization. We conclude that p-d exchange interaction leads to localization of magnetic polarons. Quantum fluctuations of the antiferromagnet strengthen this effect and make the formation of polarons localized in one site possible even for weak p-d coupling. Total energy calculations, including the kinetic energy, do not change essentially the phase diagram of magnetic polarons formation. For parameters reasonable for high-Tc superconductors either a polaron localized on one lattice cell or a small ferron can form. For reasonable values of the dielectric function and p-d coupling, the contributions of magnetic and phonon terms in the formation of a polaron in weakly doped high-Tc materials are comparable.