#include <bits/stdc++.h>
#define ll long long

using namespace std;

ll power (ll br, int exp){
    if (exp == 0) return 1;
    ll pom = power(br, exp/2);
    if (exp % 2) return pom * pom * br;
    else return pom * pom;
}

int main()
{
    ll v;
    cin >> v;
    ll res = 0;
    int brcif = 0;
    ll kop = v;
    while (kop > 9){
        kop/=10;
        ++brcif;
    }
    int pok = 0;
    if (v == 1) pok = 1;
    else if (v >= 2 && v <= 4) pok = 2;
    else pok = 3;
    ll trn = pow (10, brcif);
    if (pok == 2) trn *= 2;
    else if (pok == 3) trn *= 5;
    while (v > 0){
        while (v >= trn) {
            v -= trn;
            res++;
        }
        if (pok == 3){
            trn *= 2;
            trn /= 5;
            pok = 2;
        }
        else if (pok == 2){
            trn /= 2;
            pok = 1;
        }
        else{
            trn /= 2;
            pok = 3;
        }
    }
    cout << res;
    return 0;
}