Polycarpus enjoy study Berland hieroglyph once Polycarp got hold ancient Berland picture draw circle hieroglyph we know hieroglyph occur twice second circle occur thempolycarpu want save picture laptop problem laptop allow write hieroglyphs circle so Polycarp break circle write hieroglyph clockwise order line a line obtain circle call line obtain second call bThere way break hieroglyphic circle Polycarpus choose method make length large substre string occur subsequence stre b maximumhelp Polycarpus find maximum possible length desire substre subsequence second circle break optimallythe length string s number character if denote length string s s write string ss1s2 ssa substre s nonempty string xsa bsasa1 sb 1abs for example code force substrings codeforce coder a subsequence s nonempty string ysp1p2 pysp1sp2 spy 1p1p2pys for example coder subsequence codeforce