#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void razmeni (char *a, char *b)
{
    char x=*a;
    *a=*b;
    *b=x;
}
int palindrom (char *s)
{
    char *p1;
    char *p2;
    p1=s;
    p2=s;
    while (*p2) p2++;
    p2--;
    while (p1<p2)
    {
        if (*p1!=*p2)
            return 0;
        p1++; p2--;
    }
    return 1;
}
int g(char *s, int l, int k)
{
    if (l!=k)
    {
        for (int i=l; i<=k; i++)
        {
            razmeni(s+i, s+l);
            g(s, l+1, k);
            razmeni(s+i, s+l);
            if (palindrom(s))
                return 1;
        }
    }
    else return 0;
}
int f(char *s)
{
    if (palindrom(s))
        return 1;
    int k=strlen(s);
    int m=k;
    for (int i=2; i<=k; i++)
    {
        for (int j=0; j<=m-i; j++)
        {
            if (g(s, j, j+i-1))
                return i;
        }
    }
}
int main ()
{
    static char t[100];
    gets(t);
    printf("%d", f(t));


    return 0;
}