  We address optimization of the spin current intensity profile needed to
achieve spin torque switching of a nanomagnet. For systems with Ohmic
dissipation we prove that the optimal current drives the magnetization along
the trajectory, which is exact time-reversed replica of the relaxation
trajectory towards the equilibrium. In practice it means that the optimal
current is very nearly {\em twice} the minimal critical current needed to
switch the magnet. Pulse duration of such an optimal current is a slow
logarithmic function of temperature and the required probability of switching.
