#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int a[1001][1001];

int fun(string ss)
{
    int num = 0;
    int len = ss.length();
    string s2 = ss;
    memset(a, 0, sizeof(a));
    reverse(s2.begin(), s2.end());
    for (int i = 1; i <= len; i++)
    {
        for (int j = 0; j <= len; j++)
        {
            if (ss[i] == s2[j])
            {
                a[i][j] = a[i - 1][j - 1] + 1;
            }
            else
            {
                a[i][j] = max(a[i - 1][j], a[i][j - 1]);
            }
        }
    }
    num = len - a[len][len];
    return num;
}
int main()
{
    string s;
    cin >> s;
    cout << fun(s);
    return 0;
}
