using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, br = 0, m, br1 = 0, a, b, c, d, e, f;
            n = int.Parse(Console.ReadLine());
            for (int i = n; i != 0; i = i / 10)
            {
                m = n % 10;
                if (i != 0)
                    br++;
                else
                    br = br;
            }
            a = n % 10;
            b = (n % 100) / 10;
            c = (n % 1000) / 100;
            d = (n % 10000) / 1000;
            e = (n % 100000) / 10000;
            f = (n % 1000000) / 100000;
            if (a != b && a != c && a != d && a != e && a != f && b != c && b != d && b != e && b != f && c != d && c != e && c != f && d != e && d != f && e != f)
                Console.WriteLine(0);
            else if (br == 6)
                Console.WriteLine(br / 3);
            else
                Console.WriteLine(4);

        }
    }
}