void main(){ import std.stdio, std.string, std.conv, std.algorithm; auto s=readln.chomp.to!(char[]); int n=s.length.to!(int); bool can(int len){ if(len>n) return false; int na=0, nb=0; foreach(i; 0..n){ if(i=len) return true; } return false; } int ok=-1, ng=n+1; while(ng-ok>1){ auto m=(ng+ok)/2; if(m&1){ auto res_l=can(m-1), res_r=can(m+1); if(res_l==true && res_r==false){ ok=m-1; break; }else if(res_l==true && res_r==true){ ok=m; }else if(res_l==false && res_r==false){ ng=m; } }else{ (can(m)?ok:ng)=m; } } writeln(ok); } void rd(T...)(ref T x){ import std.stdio, std.string, std.conv; auto l=readln.split; assert(l.length==x.length); foreach(i, ref e; x) e=l[i].to!(typeof(e)); }