#include #include #include #include #include #include #include #include #include #include #include #include #define INF 1000000000 using namespace std; typedef long long int ll; typedef pair P; int main() { string s; cin>>s; int n=s.length(); int c[200001]; c[0]=0; for(int i=0; ii) m1[c[i]+200000]=i; if(m2[c[i]+200000]ans) ans=m2[i]-m1[i]; } printf("%d\n", ans); return 0; }