Construct a free body diagram as follows:
Note that directly opposing the frictional force with the magnetic force is not the optimal configuration. An upward component of the magnetic force can be used to lower the normal force and thus the frictional force.
Consider the equilibrium conditions, balance of forces in the horizontal and vertical directions.
This should lead to an expression for the magnetic field needed:
which should be optimized for theta by differentiating and setting equal to zero. After finding the optimum angle, then solve for the minimum B.