# 1222 密码脱落
# 区间DP 左右区间的状态转移要想清楚,状态间的同等关系要想清楚
li = input()
le = len(li)
dp = [[0 for _ in range(le + 10)] for _ in range(le + 10)]
for i in range(1, le + 1):
j = 0
while(i + j - 1 < le):
l, r = j, i + j - 1
if i == 1:
dp[l][r] = 1
else:
if li[l] == li[r]:
dp[l][r] = dp[l + 1][r - 1] + 2
if dp[l][r - 1] > dp[l][r]:
dp[l][r] = dp[l][r - 1]
if dp[l + 1][r] > dp[l][r]:
dp[l][r] = dp[l + 1][r]
j += 1
print(le - dp[0][le - 1])