Key length of Vigenère cipher
CJam, 67 bytes

Definitely still room for improvement, but I'll post what I have so far.

Try it online

0r:T,,ri&gt;{T,L(-,_m*{~:XT&gt;L&lt;T@LX+e&gt;,{0t}/X&gt;\#_W&gt;\2$?{\1$_!+%}h;}/}fL