#include <bits/stdc++.h>
using namespace std;

const int N = 200005;

int cnt[N][30];

int solve(string str, int n, int start){
    for(int j = 0; j < 26; ++j)
        cnt[0][j] = 0;

    cnt[0][str[0] - 'a']++;
    for(int i = 1; i < n; ++i){
        for(int j = 0; j < 26; ++j)
            cnt[i][j] = cnt[i - 1][j];
        cnt[i][str[i] - 'a']++;
    }

    for(int i = start; i <= n - start - 1; ++i){
        bool contained = true;
        for(int j = 0; j < 26; ++j){
            if((cnt[i][j] - (start - 1 >= 0 ? cnt[start - 1][j] : 0)) < (cnt[n - start - 1][j] - cnt[i][j])){
                contained = false;
                break;
            }
        }
        if(contained){
            return i - start + 1;
        }
    }
    return n;
}

int main()
{
    string str;
    cin >> str;
    int n = str.size();
    int start = -1;
    for(int i = 0; i <= n / 2; ++i){
        if(str[i] != str[n - i - 1]){
            start = i;
            break;
        }
    }
    if(start == -1){
        cout << "1\n";
        return 0;
    }

    int r1 = solve(str, n, start);
    reverse(str.begin(), str.end());
    int r2 = solve(str, n, start);
    int res = min(r1, r2);
    cout << res << "\n";
    return 0;
}