#include <iostream>

using namespace std;

int main()
{
    long long n;
    int br = 0;
    cin >> n;
    while (n > 0) {
        int x = n % 10;
        n /= 10;
        while (x > 0) {
            if (x >= 5) {
                x -= 5;
                br++;
                continue;
            }
            if (x >= 2) {
                x -= 2;
                br++;
                continue;
            }
            if (x >= 1) {
                x -= 2;
                br++;
                continue;
            }
        }
    }
    cout << br;
    return 0;
}