// 上海2023.8 动态规划:最长回文
//思路:先存一下s的备份t,将s倒转,然后 计算 s 与t 的最长公共子序列长度 (动态规划)
// 然后 len-dp【len][len];
#include<bits/stdc++.h>
using namespace std;
int dp[2005][2005];
int main()
{
string s,t;
cin>>s;
t=s;
reverse(s.begin(),s.end());
//判断t 与s的公共的子序列的最大长度
int i,j,len=s.size();
for(i=1;i<=len;i++)
{
for(j=1;j<=len;j++)
{
if(s[i-1]==t[j-1])
{
dp[i][j]=dp[i-1][j-1]+1;
}
else
{
dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
}
}
}
cout<<len-dp[len][len];
return 0;
}