#include <iostream>
#include <string>
#include <vector>
using namespace std;

bool provera_listi(vector<int> k1, vector<int> k2) {
    for (int i = 0; i < 26; i++)
        if (k1[i] > k2[i])
            return false;
    return true;
}

int kretnja(string s, int poc, int kraj, int korak, vector<int> k1, vector<int> k2) {
    if (provera_listi(k1, k2))
        return 0;
    int x = 1;
    while (poc != kraj) {
        if (!(x == 1 && s.length() % 2 == 1))
            k1[s[poc] - 'a']--;
        k2[s[poc] - 'a']++;
        if (provera_listi(k1, k2))
            return x;
        poc += korak;
        x++;
    }
}

int main() {
    ios::sync_with_stdio(false);

    string s;
    getline(cin, s);
    int duz = s.length();
    int br_pg = 0, br_pd = 0;
    bool g1 = true, g2 = true;
    vector<int> k1(26); vector<int> k2(26);

    for (int i = 0; i < duz / 2; i++) {
        k1[s[i] - 'a']++;
        k2[s[duz - 1 - i] - 'a']++;
        if (g1 && s[duz - 1 - i] == s[i])
            br_pg++;
        else
            g1 = false;
        if (g2 && s[duz / 2 - 1 - i] == s[duz / 2 + i + (int)(duz % 2 == 1)])
            br_pd++;
        else
            g2 = false;
    }
    int zamena = duz / 2 - br_pg - br_pd;
    if (br_pd == 0) {
        int levo = zamena + (duz % 2 == 1 ? kretnja(s, duz / 2, -1, -1, k1, k2) : kretnja(s, duz / 2 - 1, -1, -1, k1, k2));
        int desno = zamena + kretnja(s, duz / 2, duz, 1, k2, k1);
        zamena = min(levo, desno);
    }
    cout << max(zamena, 1) << endl;
}