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

typedef long long ll;

const int N = 1e6 + 10;
ll a[N];

ll init(const ll v) {
    ll pow = 1;
    ll last = 1;
    ll i = 0;
    while (last < v) {
        a[i] = 1 * pow;
        last = a[i];
        if (last >= v) break;
        i++;
        a[i] = 2 * pow;
        last = a[i];
        if (last >= v) break;
        i++;
        a[i] = 5 * pow;
        last = a[i];
        if (last >= v) break;
        i++;
        pow = pow * 10;
    }
    return i;
}

int main () {
    ios::sync_with_stdio(false);
    ll v, res = 0, number;

    cin >> v;
    number = init(v);

    // for (ll i = 0 ; i < number ; i++) cout << a[i] << " ";
    // cout << "\n";

    for (ll i = number ; i >= 0 ; i--) {
        ll tmp;
        tmp = v / a[i];
        res += tmp;
        v -= tmp * a[i];
    }

    cout << res << "\n";

    return 0;
}