#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstdio>
using namespace std;
string a;
long long b,c,d;
int main() {
    cin >> a;
    b = a.size();
    for (int i = 0; i < b; i++) {
        if (a[i] == a[b - 1 - i])c = c + 2;
        else break;
    }
    if (c == b - 1 or c == b)cout << "1" << endl;
    else if (c != b - 1) {
        for (int i = c / 2 + 2; i <= b - c / 2 - 1; i++) {
            if (a[c / 2 + 1] == a[i]) {
                cout << b - (c + 1) << endl;
                d = 1;
            }
        }
        for (int i = c / 2 + 1; i <= b - c / 2 - 1; i++) {
            if (d == 1)break;
            else if(d != 1) {
                if (a[b - c / 2 - 1] == a[i]) {
                    cout << b - (c + 1) << endl;
                    break;
                }
            }
        }
    }
    else cout << b - c << endl;
    return 0;
}