#include <bits/stdc++.h>


#define f(n) for (int i = 0; i < n; i++)
#define f0(n) for (int j = 0; j < n; j++)
#define co(n) cout << n << "\n";

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    string t;
    cin >> t;
#define td (int)t.length()
    map<char, deque<int>> m;
    f(td) m[t[i]].push_back(i);
    int l = td - 1, d = 0;
    for (char c = 'a'; c < 'z'; c++)
    {
        if (m[c].size() % 2 == 1)
        {
            l = min(m[c][m[c].size() / 2], (int)td / 2);
            d = max(m[c][m[c].size() / 2], (int)td / 2);
            m[c].clear();
            break;
        }
    }
    int ml = 0, md = 0;
    for(char c = 'a'; c < 'z'; c++)
    {
        while (!m[c].empty())
        {
            if (m[c].front() != td - 1 - m[c].back())
            {
                int ll = min(l, min(m[c].front(), td - 1 - m[c].back())), ld = max(d, max(m[c].front(), td - 1 - m[c].back()));
                int dl = min(l, min(m[c].back(), td - 1 - m[c].front())), dd = max(d, max(m[c].back(), td - 1 - m[c].front()));
                if (ld - ll < dd - ld)
                {
                    l = ll;
                    d = ld;
                }
                else
                {
                    l = dl;
                    d = dd;
                }
            }
            m[c].pop_back();
            m[c].pop_front();
        }
    }
    cout << max(d - l + 1, 1);
}