const maxn = 255;
var i,j,k,n:byte;
s:string;
f: array[0..maxn+1,0..maxn+1] of boolean;
dp: array[0..maxn] of byte;
begin
readln(s);
n:=length(s);
for i:=0 to n do
for j:=0 to n do
f[i,j]:=false;
for i:=0 to n do
f[i,i]:=true;
for k:=1 to n-1 do
for i:=1 to n-k do
begin
j:=i+k;
f[i,j]:=(f[i+1,j-1] and (s[i]=s[j])) or ((j-i=1) and (s[i]=s[j]));
end;
fillchar(dp,sizeof(dp),maxn);
dp[0]:=0;
for i:=1 to n do
begin
for j:=1 to i do
if f[j,i] and (dp[j-1]+1<dp[i]) then dp[i]:=dp[j-1]+1;
end;
writeln(dp[n]);
end.
Y29uc3QgbWF4biA9IDI1NTsKdmFyIGksaixrLG46Ynl0ZTsKICAgIHM6c3RyaW5nOwogICAgZjogYXJyYXlbMC4ubWF4bisxLDAuLm1heG4rMV0gb2YgYm9vbGVhbjsKICAgIGRwOiBhcnJheVswLi5tYXhuXSBvZiBieXRlOwpiZWdpbgogIHJlYWRsbihzKTsKICBuOj1sZW5ndGgocyk7CiAgZm9yIGk6PTAgdG8gbiBkbwogIGZvciBqOj0wIHRvIG4gZG8KICBmW2ksal06PWZhbHNlOwogIGZvciBpOj0wIHRvIG4gZG8KICBmW2ksaV06PXRydWU7CiAgZm9yIGs6PTEgdG8gbi0xIGRvCiAgZm9yIGk6PTEgdG8gbi1rIGRvCiAgYmVnaW4KICAgIGo6PWkrazsKICAgIGZbaSxqXTo9KGZbaSsxLGotMV0gYW5kIChzW2ldPXNbal0pKSBvciAoKGotaT0xKSBhbmQgKHNbaV09c1tqXSkpOwogIGVuZDsKICBmaWxsY2hhcihkcCxzaXplb2YoZHApLG1heG4pOwogIGRwWzBdOj0wOwogIGZvciBpOj0xIHRvIG4gZG8KICBiZWdpbgogICAgZm9yIGo6PTEgdG8gaSBkbwogICAgaWYgZltqLGldIGFuZCAoZHBbai0xXSsxPGRwW2ldKSB0aGVuIGRwW2ldOj1kcFtqLTFdKzE7CiAgZW5kOwogIHdyaXRlbG4oZHBbbl0pOwplbmQu