Given that

$\displaystyle 3\,\sum _{m=1}^{M} \left( \cot \left( {\frac {m\pi }{2\,M+1}} \right)

\right) ^{2}$

is a polynomial of degree r in M, find r and the coefficient of $\displaystyle M^r$.(The coefficient is an integer)

Any ideas how to go about solving this problem?