#include<iostream>
#include<vector>

void make_nv(std::vector<unsigned long long>& nv){
    const int da[] = {1, 2, 5};
    unsigned long long e = 1;
    for(int i = 0; i < 19; ++i){
        for(auto& d : da){
            nv.push_back(d * e);
        }
        e *= 10;
    }
}

int main(){
    std::vector<unsigned long long> nv;
    unsigned long long v;
    int nk = 0;

    make_nv(nv);
    int k = nv.size() - 1;

    std::cin >> v;

    while(v != 0){
        if(v / nv[k] == 0){
            --k;
        }
        else{
            nk += v / nv[k];
            v = v % nv[k--];
        }
    }

    std::cout << nk << std::endl;

    return 0;
}