#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
char str[N];
int dp[N][N];
int n;
int main()
{
cin >> str;
n = strlen(str);
for (int len = 1; len <= n; len ++ )
for (int l = 0; l + len - 1 < n; l ++ )
{
int r = l + len - 1;
if (len == 1) dp[l][r] = 1;
else
{
dp[l][r] = max(dp[l + 1][r], dp[l][r - 1]);
if (str[l] == str[r]) dp[l][r] = max(dp[l][r], dp[l + 1][r - 1] + 2);
}
}
printf("%d\n", n - dp[0][n - 1]);
return 0;
}