#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 1010;
int f[N][N];
string s;
int main()
{
cin >> s;
for (int len = 2; len <= s.size(); len ++ )
for (int i = 0; i + len - 1 < s.size(); i ++ )
{
int j = i + len - 1;
if (s[i] == s[j]) f[i][j] = f[i + 1][j - 1];
else f[i][j] = min(f[i + 1][j], f[i][j - 1]) + 1;
}
cout << f[0][s.size() - 1] << endl;
return 0;
}