#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    unsigned long long int v,k,brn,x;
    cout<<"unesite sumu v"<<endl;
    cin>>v;
    brn=0;

        for( k=18 ; k>=0 ; k-- )
        {
            if( 0 != v/(5*pow(10,k)))
            {
                x =  v/(5*pow(10,k));
                v = v-x*(5*pow(10,k));
                brn = brn+x;
            }

            if( 0 != v/(2*pow(10,k)))
            {
                x =  v/(2*pow(10,k));
                v = v-x*(2*pow(10,k));
                brn = brn+x;

            }

            if( 0 != v/(1*pow(10,k)))
            {
                x =  v/(1*pow(10,k));
                v = v-x*(1*pow(10,k));
                brn = brn+x;

            }

        }
    cout<<brn<<endl;
    return 0;
}