#include <bits/stdc++.h>

using namespace std;

int main()
{
    unsigned long long int suma, jedan=1, dva=2, pet=5;
    unsigned int brojCifara, brojac=0;
    cin >> suma;
    brojCifara=to_string(suma).length();
    for(unsigned int i=1;i<brojCifara;i++){
        jedan*=10;
        dva*=10;
        pet*=10;
    }
    while(suma){
        while(pet<=suma){
            suma-=pet;
            brojac++;
        }
        while(dva<=suma){
            suma-=dva;
            brojac++;
        }
        while(jedan<=suma){
            suma-=jedan;
            brojac++;
        }
        pet/=10;dva/=10;jedan/=10;
    }
    cout << brojac;
}