#include<bits/stdc++.h>

using namespace std;

main()
{
    int brojac=0,b,i=0,brojac1=0,m=0,brojac2=0,brojac3=0,d=1;
    long long int n;
    cin>>n;
    int a=n,n1=n,n2=0;
    while(a!=0)
    {
        a=a/10;
        brojac++;
    }
    int x[brojac],mi=brojac;

    while(n1/10!=0)
	{
		n2+=n1%10*d;

		if(n1%10==(n1%100)/10)
			n1/=100;
		else
			n1/=10;

		d*=10;
	}
	n2+=n1*d;

    while(n2!=0)
    {
        b=n2%10;
        n2=n2/10;
        x[i]=b;
        i++;
    }
    int y=i;
    for(int i=0;i<y;i++)
    {
        for(int j=i+1;j<y;j++)
        {
            if(x[i]==x[j])
                if(i+1!=j)
                    brojac1++;

        }
        if(brojac1>=m)
            m=brojac1;
        brojac1=0;

    }
    cout<<m<<endl;
}