#include <bits/stdc++.h>
using namespace std;

#define ll long long

ll v;
ll nov[55];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    ll s = 0;
    ll help = 1;
    for(ll i = 0; i < 18; ++i){
        nov[s++] = help;
        nov[s++] = 2 * help;
        nov[s++] = 5 * help;
        help *= 10;
    }

    cin >> v;

    ll res = 0;
    for(ll i = s - 1; i >= 0; --i){
        ll help = v / nov[i];
        res += help;
        v -= help * nov[i];
    }

    cout << res << "\n";

    return 0;
}