根据python3.0
import sys
def maxlcp(strs):
if strs == None or len(strs) == 0:
return 0
lens = len(strs)
dp = [0] * lens
dp[0] = 1 if strs[0] == strs[lens - 1] else 0
for i in range(lens):
pre = dp[0]
dp[0] = max(dp[0], 1 if strs[i] == strs[lens - 1] else 0)
for j in range(1, lens):
cur = dp[j]
dp[j] = max(dp[j], dp[j - 1])
if strs[i] == strs[lens - 1 - j]:
dp[j] = max(dp[j], pre + 1)
pre = cur
return dp[lens - 1]
if __name__ == '__main__':
while True:
line = sys.stdin.readline().strip()
lens = len(line)
if not line:
break
maxLcp = maxlcp(line)
print(lens - maxLcp)