#include <iostream>
#include <cmath>

using namespace std;

long long v,d,f, h;
int i, brojac,c,g;

void kvadriranje(){
    h=1;
    for( g=i; g > 0; g--){
        h=10*h;
    }
    return;
}

int main (){
    cin >> v;
    f=v;
    while (f>0){
        f = (f-f%10)/10;
        c++;
    }
    i = c-1;
    for ( ; i>=0; i--){
        kvadriranje();
        brojac += v/(5*h);
        d = v/(5*h);
        v -= d*h*5;

        brojac += v/(2*h);
        d = v/(2*h);
        v -= d*h*2;

        brojac += v/h;
        d = v/h;
        v -= d*h;
    }

    cout << brojac << endl;
return 0;
}