#include <bits/stdc++.h>

using namespace std;


int main()
{
    unsigned long long v;
    scanf("%llu",&v);
    double niz[]={3,3,2,2,1,2,2,1,1,0};
    unsigned long long x=v;
    double rez=0;
    while(x>9)
    {
        rez=rez+niz[9-(x%10)];
        x=x/10;
    }
    rez=rez+niz[9-x];
    cout<<rez<<"\n";
    return 0;
}