A set of spins interact with each other by an arbitrary anisotropic interaction and with external magnetic field. The field varies linearly with time and thus induces spin flips. If initially all spins are oriented in the same direction, then the probability of demagnetization is given exactly by a simple analytical expression. Depending on parameter values the spin-spin interactions might enhance or decrease the probability of demagnetization.