#pragma comment(linker, "/STACK:102400000,102400000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define Key_Value ch[ch[root][1]][0]
#define DBN1(a)           cerr<<#a<<"="<<(a)<<"\n"
#define DBN2(a,b)         cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define DBN3(a,b,c)       cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define DBN4(a,b,c,d)     cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define DBN5(a,b,c,d,e)   cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<"\n"
#define DBN6(a,b,c,d,e,f) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<", "<<#e<<"="<<(e)<<", "<<#f<<"="<<(f)<<"\n"
#define clr(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define f first
#define s second
#define ALL(x) x.begin(),x.end()
using namespace std;
typedef long long ll;
const int maxn=500000+5;
const int INF=0x3f3f3f3f;
const int P=1000000007;
const double PI=acos(-1.0);
template<typename T>
inline T read(T&x){
    x=0;int _f=0;char ch=getchar();
    while(ch<'0'||ch>'9')_f|=(ch=='-'),ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x=_f?-x:x;
}
template <class T1, class T2>inline void gmax(T1 &a,T2 b){if (b>a) a=b;}
template <class T1, class T2>inline void gmin(T1 &a,T2 b){if (b<a) a=b;}
/*int a,b;
int main(){
    read(a),read(b);
    if ((a+b)%2==0) cout<<(a+b)/2<<endl;
    else cout<<(a+b+1)/2<<endl;
    return 0;
}*/
/*string s,t;
int main(){
    cin>>s>>t;
    sort(ALL(s));
    sort(ALL(t));
    reverse(ALL(t));
    if (s<t) puts("Yes");
    else puts("No");
    return 0;
}*/
/*const int N=1e5+5;
int n,a[N],cnt[N];
int main(){
    read(n);
    int ans=0;
    for (int i=1;i<=n;i++){
        read(a[i]);
        if (a[i]>1e5) ans++;
        else cnt[a[i]]++;
    }
    for (int i=1;i<=1e5;i++){
        if (cnt[i] && cnt[i]!=i){
            ans+=cnt[i]<i?cnt[i]:cnt[i]-i;
        }
    }
    cout<<ans<<endl;
    return 0;
}*/
/*const int N=2e5+10;
int a[maxn],sum,n;
vector<int>vec;
int main(){
    read(n);
    for (int i=1;i<=n;i++) read(a[i]),sum+=a[i];
    for (int i=1;i<=n;i++){
        if ((sum-a[i])==a[i]*(n-1)) vec.push_back(i);
    }
    printf("%d\n",vec.size());
    for (int i=0;i<(int)vec.size();i++) printf("%d ",vec[i]);
    return 0;
}*/
/*int n,d;
char s[105];
int main(){
    read(n),read(d);
    scanf("%s",s+1);
    int len=strlen(s+1);
    int pre=1,cnt=0;
    for (;;){
        if (pre+d>=len){
            pre=len;
            cnt++;
            break;
        }
        bool flag=false;
        for (int i=pre+d;i>=pre+1;i--){
            if (s[i]=='1'){
                flag=true;
                pre=i;
                cnt++;
                break;
            }
        }
        if (!flag) break;
    }
    if (pre==len) cout<<cnt<<endl;
    else puts("-1");
    return 0;
}*/
/*int n,a,b;
vector<int>vec;
int pos[6];
int main(){
    read(n),read(a),read(b);
    for (int i=0;i<4;i++) vec.pb(a);
    for (int i=0;i<2;i++) vec.pb(b);
    for (int i=0;i<6;i++) pos[i]=i;
    int ans=INF;
    do{
        int tmp=1,cur=n;
        for (int i=0;i<6;i++){
            if (cur-vec[pos[i]]<0){
                cur=n-vec[pos[i]];
                tmp++;
            }
            else cur-=vec[pos[i]];
        }
        ans=min(ans,tmp);
    }while (next_permutation(pos,pos+6));
    cout<<ans<<endl;
    return 0;
}*/
/*int n;
char s[1005][10];
int len[1005];
int pos[10];
int main(){
    for (int i=0;i<10;i++) pos[i]=i;
    read(n);
    for (int i=1;i<=n;i++){
        scanf("%s",s[i]);
        len[i]=strlen(s[i]);
    }
    ll ans=1e18;
    do{
        ll tmp=0;
        bool flag=true;
        for (int i=1;i<=n;i++){
            ll tmp2=0;
            for (int j=0;j<len[i];j++){
                if (j==0 && pos[s[i][j]-'a']==0){
                    flag=false;
                    break;
                }
                else tmp2=tmp2*10+(pos[s[i][j]-'a']);
            }
            tmp+=tmp2;
            if (tmp>=ans) flag=false;
            if (!flag) break;
        }
        if (flag) ans=min(ans,tmp);
    }while (next_permutation(pos,pos+10));
    cout<<ans<<endl;
    return 0;
}*/
int main(){
    string s;
    cin>>s;
    int ans=INF,len=s.length();
    for (int i=0;i<len-1;i++){
        if (s[i]!=s[i+1]) ans=min(ans,max(len-i-1,i+1));
    }
    if (ans==INF) cout<<len<<endl;
    else cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512