#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)

using namespace std;

using namespace __gnu_pbds;


bool palindrom(string t){
    for(int i = 0, j = t.size() - 1; i < t.size() / 2; i++, j--){
        if(t[i] != t[j]){
            return false;
        }
    }
    return true;
}
int main()
{

    string t; cin >> t;
    int ms, me, e;

    if(palindrom(t)){
        cout << 1 << endl;
        return 0;
    }

    for(int i = 0, j = t.size() - 1; i < t.size() / 2; i++, j--){
        if(t[i] != t[j]){
            ms = i;
            me = j;
            break;
        }
    }

    //cout << ms << " - " << me << endl;

    bool check = true;

    if(t[ms] == t[ms + 1]){
        check = false;
    }
    if(check){
        for(int i = me; i > ms; i--){
            if(t[i] != t[me]){
                me = i + 1;
                break;
            }
        }
    }
    else{
        for(int i = ms; i < me; i++){
            if(t[ms] != t[i]){
                ms = i - 1;
                break;
            }
        }
    }


    e = me - ms + 1;

    //cout << ms << " - " << me << endl;
    cout << e << endl;
    return 0;
}