#include <iostream>

int v,s;

using namespace std;

int BrI(int x)
{
    int k=0;
    
    if(x>=5)
    {
        x=x-5;
        k++;
    }
    
    while(x>=2)
    {
        x=x-2;
        k++;
    }
    
    if(x==1)
        k++;
    
    return k;
}


int main()
{
    cin >> v;
    
    int p;
    
    while(v>1)
    {
        p=v%10;
        v=(v-p)/10;
        s=s+BrI(p);
    }
    
    cout << s;

    return 0;
}