#include <iostream>
using namespace std;
int main()
{
    unsigned long long v, k=0, z;
    cin>>v;
    while(v>0){
        z=v%10;
        if(z<10&&z>=5){
            v=v-5;
            k++;
        }
        if(z<5&&z>1){
            v=v-2;
            k++;
        }
        if(z==1){
            v=v-1;
            k++;
        }
        if(z==0){
           v=v/10;
        }
    }
    cout<<k<<endl;
    return 0;
}