#include <iostream>
#include <stdlib.h>
#include <stdio.h>

int main()
{
    long long  V = 121412181214006947, resenje = 0;
    short trenKolicinik;
    while(V != 0)
    {
        trenKolicinik = V % 10;
        switch(trenKolicinik)
        {
        case 9:
        case 8:
            resenje += 3;
            break;
        case 7:
        case 6:
        case 4:
        case 3:
            resenje += 2;
            break;
        case 5:
        case 2:
        case 1:
            resenje += 1;
            break;
        case 0:
            break;
        }
        V /= (long long)10;
    }
    printf("%lld",resenje);
}