#include <iostream>

using namespace std;
int a[10];
int main()
{
    long long x;
    cin >> x;
    long long t = x;
    int temp;
    int j = 0;
    bool f = true;
    while(t > 0)
    {
        int d = t % 10;
        if(j == 0)
        {
            temp = d;
            a[d - 1] = 1;
        }
        else
        {
            if(d != temp)
            {
                if(a[d - 1] == 0)
                {
                    a[d - 1] = 1;
                    temp = d;
                }
                else
                {
                    f = false;
                }
            }
        }
        j++;
        t /= 10;
    }
    if(f)
    {
        cout << "0" << endl;
    }
    else
    {
        cout << "3" << endl;
    }
    return 0;
}