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

ll coins[] = {5, 2, 1};

ll greedy(ll c) {

    ll num = 0;
    for (int i = 0; i < 3; ++i)
        while (c >= coins[i]) {
            c -= coins[i];
            ++num;
        }

    return num;
}

int main()
{
    ll v; cin >> v;

    ll res = 0;
    while (v) {

        ll cifra = v%10;

        res += greedy(cifra);

        v /= 10;

    }

    cout << res;
    return 0;
}