#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repp(i, m, n) for(int i = m; i < n; i++)
#define reps(i, n) for(int i = 1; i <= n; i++)
const int    INF = 100000000;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int, int> pai;
typedef pair<ll,ll> pal;



int main()
{
	string s;
	cin >> s;
	char t[30][200010];
	map<string, int> table;
	rep(i, 26) t[i][0]='0';
	rep(i, s.size())
	{
		rep(j, 26)
		{
			if(j==(int)s[i]-(int)'a')
			{
				if(t[j][i]=='0') t[j][i+1]='1';
				else t[j][i+1]='0';
			}
			else t[j][i+1]=t[j][i];
		}
	}
	string u[200010]={};
	rep(i, s.size()+1) rep(j, 26) u[i]+=t[j][i];
	int tmp=0;
	rep(i, s.size()+1)
	{
		if(table.find(u[i])==table.end())
		{
			table.insert((u[i], tmp));
			tmp++;
		}
	}
	int e[400010];
	rep(i, 2*s.size()+2) e[i]=-1;
	rep(i, s.size()+1)
	{
		if(e[2*table[u[i]]+i%2]==-1) e[2*table[u[i]]+i%2]=i;
	}
	int dp[200010]={};
	string x, y;
	int k, l, ml, mr, mm;
	reps(i, s.size())
	{
		dp[i]=500000;
		x=u[i];
		rep(j, 26)
		{
			y=x;
			if(y[j]=='0') y[j]='1';
			else y[j]='0';
			if(table.find(y)!=table.end())
			{
				k=2*table[y];
				if(i%2==0) k++;
				ml=e[k];
				if(ml==-1 || ml>=i) continue;
				else dp[i]=min(dp[i], dp[ml]+1);
			}
		}
	}
	if(u[s.size()]!=u[0]) cout << dp[s.size()] << endl;
	else cout << '1' << endl;
	return 0;
}