#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    long cena;
    cin >> cena;
    int n = 0;
    int k = 0;
    int d;
    int niz[] = {1, 2, 5};
    
    while (cena >= pow(10, k)){
        k++;
    }
    
    while((k >= 0) && (cena >= 0)){
        d = 2;
        while((d >= 0) && (cena >= 0)){
            while (cena >= niz[d]*(pow(10, k))){
                cena -= niz[d]*(pow(10, k));
                n++;
            } 
            d--;
        }
        k--;
    }
    
    cout << n;

}