OK, great. Since you let T = 0, the equation you have derived is going to give you the mass of the ring that would make the tension go to zero when the beads reach the angle theta.
You are trying to find the maximum value that M can have and still have the tension go to zero. That means that you need to find the angle theta that would make the right hand side of the equation take on its maximum possible value.
Usually finding the maximum value of a function requires calculus. But, here it turns out we can get it without calculus. For convenience, suppose we let the symbol x stand for cosθ. Since theta is a variable, so is x. What does your equation for M look like in terms of x?