#import <iostream>
#import <cmath>
#import <string>
#import <map>
#import <vector>
#import <functional>
using namespace std;

int main(){
    string rec;
    cin >> rec;
    int len = rec.length();
    int m1 = 1;
    int m2 = 1;
    map<char, int> Map;
    Map['a'] = 0;
    Map['b'] = 0;
    Map['c'] = 0;
    Map['d'] = 0;
    Map['e'] = 0;
    Map['f'] = 0;
    Map['g'] = 0;
    Map['h'] = 0;
    Map['i'] = 0;
    Map['j'] = 0;
    Map['k'] = 0;
    Map['l'] = 0;
    Map['m'] = 0;
    Map['n'] = 0;
    Map['o'] = 0;
    Map['p'] = 0;
    Map['q'] = 0;
    Map['r'] = 0;
    Map['s'] = 0;
    Map['t'] = 0;
    Map['u'] = 0;
    Map['v'] = 0;
    Map['w'] = 0;
    Map['x'] = 0;
    Map['y'] = 0;
    Map['z'] = 0;
    bool start = false;
    int l = 0;
    int r = 0;
    bool finish = false;
    bool pola = false;
    
    //NEPARNI BRRRRR
    
    //SPREDA
    
    if(len%2 == 1){
        for(int i = 0; i < len; i++){
            if(rec[i] != rec[len - i - 1]){
                if(not start){
                    l = i;
                    start = true;
                }
                if(not pola){
                    Map[rec[i]]++;
                    Map[rec[len - i - 1]]--;
                    finish = false;
                }else{
                    if(Map[rec[i]] != 0){
                        Map[rec[i]] += 2;
                    }
                    finish = false;
                }
            }
            if(start){
                if(i == len/2){
                    pola = true;
                    int z = 0;
                    char c1 = '*';
                    char c2 = '*';
                    for(auto &eli: Map){
                        if(eli.second != 0){
                            z++;
                            if(eli.second == -1){
                                c1 = eli.first;
                                if(c1 == rec[i]) Map[c1] = 0;
                                else Map[c1]--;
                            }else if(eli.second == 1){
                                c2 = eli.first;
                                Map[c2]++;
                            }
                        }
                    }
                    if(z == 0){
                        m1 = r - l + 1;
                        break;
                    }else if(z == 2){
                        if(c1 == rec[i] and c2 != '*'){
                            m1 = i - l + 1;
                            break;
                        }
                    }
                    for(auto &eli: Map){
                        if(eli.second > 0){
                            eli.second = 0;
                        }
                    }
                }else if(not finish){
                    bool b = true;
                    for(auto &eli: Map){
                        if(eli.second != 0){
                            b = false;
                            break;
                        }
                    }
                    if(b){
                        r = i;
                        if(pola){
                            m1 = r - l + 1;
                            break;
                        }
                        finish = true;
                    }
                }
            }else{
                if(i == len/2) break;
            }
        }
        if(m1 == 1){
            cout << 1;
        }
        
        //OTPOZADI NEPARNIIIIIIII
        
        else{
            Map['a'] = 0;
            Map['b'] = 0;
            Map['c'] = 0;
            Map['d'] = 0;
            Map['e'] = 0;
            Map['f'] = 0;
            Map['g'] = 0;
            Map['h'] = 0;
            Map['i'] = 0;
            Map['j'] = 0;
            Map['k'] = 0;
            Map['l'] = 0;
            Map['m'] = 0;
            Map['n'] = 0;
            Map['o'] = 0;
            Map['p'] = 0;
            Map['q'] = 0;
            Map['r'] = 0;
            Map['s'] = 0;
            Map['t'] = 0;
            Map['u'] = 0;
            Map['v'] = 0;
            Map['w'] = 0;
            Map['x'] = 0;
            Map['y'] = 0;
            Map['z'] = 0;
            bool start = false;
            int l = 0;
            int r = 0;
            bool finish = false;
            bool pola = false;
            for(int i = len - 1; i >= 0; i--){
                if(rec[i] != rec[len - i - 1]){
                    if(not start){
                        r = i;
                        start = true;
                    }
                    if(not pola){
                        Map[rec[i]]++;
                        Map[rec[len - i - 1]]--;
                        finish = false;
                    }else{
                        if(Map[rec[i]] != 0){
                            Map[rec[i]] += 2;
                        }
                        finish = false;
                    }
                }
                if(start){
                    if(i == len/2){
                        pola = true;
                        int z = 0;
                        char c1 = '*';
                        char c2 = '*';
                        for(auto &eli: Map){
                            if(eli.second != 0){
                                z++;
                                if(eli.second == -1){
                                    c1 = eli.first;
                                    if(c1 == rec[i]) Map[c1] = 0;
                                    else Map[c1]--;
                                }else if(eli.second == 1){
                                    c2 = eli.first;
                                    Map[c2]++;
                                }
                            }
                        }
                        if(z == 0){
                            m2 = r - l + 1;
                            break;
                        }else if(z == 2){
                            if(c1 == rec[i] and c2 != '*'){
                                m2 = r - i + 1;
                                break;
                            }
                        }
                        for(auto &eli: Map){
                            if(eli.second > 0){
                                eli.second = 0;
                            }
                        }
                    }else if(not finish){
                        bool b = true;
                        for(auto &eli: Map){
                            if(eli.second != 0){
                                b = false;
                                break;
                            }
                        }
                        if(b){
                            l = i;
                            if(pola){
                                m2 = r - l + 1;
                                break;
                            }
                            finish = true;
                        }
                    }
                }else{
                    if(i == len/2) break;
                }
            }
            if(m2 < m1){
                cout << m2;
            }else{
                cout << m1;
            }
        }
    }
    
    //PARNIIIIIIIIIIIIIIIII
    
    //SPREDAAAAAAAAAAAAAA
    
    else{
        bool tacnopola = false;
        for(int i = 0; i < len; i++){
            if(rec[i] != rec[len - i - 1]){
                if(not start){
                    l = i;
                    start = true;
                }
                if(not pola){
                    Map[rec[i]]++;
                    Map[rec[len - i - 1]]--;
                    finish = false;
                }else{
                    if(Map[rec[i]] != 0){
                        Map[rec[i]] += 2;
                    }
                    finish = false;
                }
            }
            if(start){
                if(i == len/2 - 1){
                    tacnopola = true;
                    pola = true;
                    for(auto &eli: Map){
                        if(eli.second > 0){
                            eli.second = 0;
                        }
                    }
                }
                if((not finish) or tacnopola){
                    tacnopola = false;
                    bool b = true;
                    for(auto &eli: Map){
                        if(eli.second != 0){
                            b = false;
                            break;
                        }
                    }
                    if(b){
                        r = i;
                        if(pola){
                            m1 = r - l + 1;
                            break;
                        }
                        finish = true;
                    }
                }
            }else{
                if(i == len/2) break;
            }
        }
        if(m1 == 1){
            cout << 1;
        }
        
        //OTPOZADIIIIIIIIIIIIIIIIIIII
        
        else{
            Map['a'] = 0;
            Map['b'] = 0;
            Map['c'] = 0;
            Map['d'] = 0;
            Map['e'] = 0;
            Map['f'] = 0;
            Map['g'] = 0;
            Map['h'] = 0;
            Map['i'] = 0;
            Map['j'] = 0;
            Map['k'] = 0;
            Map['l'] = 0;
            Map['m'] = 0;
            Map['n'] = 0;
            Map['o'] = 0;
            Map['p'] = 0;
            Map['q'] = 0;
            Map['r'] = 0;
            Map['s'] = 0;
            Map['t'] = 0;
            Map['u'] = 0;
            Map['v'] = 0;
            Map['w'] = 0;
            Map['x'] = 0;
            Map['y'] = 0;
            Map['z'] = 0;
            bool start = false;
            int l = 0;
            int r = 0;
            bool finish = false;
            bool pola = false;
            bool tacnopola = false;
            for(int i = len - 1; i >= 0; i--){
                if(rec[i] != rec[len - i - 1]){
                    if(not start){
                        r = i;
                        start = true;
                    }
                    if(not pola){
                        Map[rec[i]]++;
                        Map[rec[len - i - 1]]--;
                        finish = false;
                    }else{
                        if(Map[rec[i]] != 0){
                            Map[rec[i]] += 2;
                        }
                        finish = false;
                    }
                }
                if(start){
                    if(i == len/2){
                        pola = true;
                        tacnopola = true;
                        for(auto &eli: Map){
                            if(eli.second > 0){
                                eli.second = 0;
                            }
                        }
                    }
                    if((not finish) or tacnopola){
                        tacnopola = false;
                        bool b = true;
                        for(auto &eli: Map){
                            if(eli.second != 0){
                                b = false;
                                break;
                            }
                        }
                        if(b){
                            l = i;
                            if(pola){
                                m2 = r - l + 1;
                                break;
                            }
                            finish = true;
                        }
                    }
                }else{
                    if(i == len/2) break;
                }
            }
            if(m2 < m1){
                cout << m2;
            }else{
                cout << m1;
            }
        }
    }
}