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

typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll res = 0;
    while(n){
        int x = n%10;
        res += x/5;
        x %= 5;
        res += x/2;
        x %= 2;
        res += x;
        n /= 10;
    }
    cout << res;
    return 0;
}