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){ len+=(len&1); 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; // writeln(ok, " ", m, " ", ng); (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)); }