#include <bits/stdc++.h>

using namespace std;

int solution(long long V)
{
    int i = 0;
    while(V != 0)
    {
        int digit = V%10;
        V /= 10;

        i+= digit/5+(digit%5)/2+(digit%5)%2;
    }
    return i;
}

int main()
{
    ios_base::sync_with_stdio(false);
    long long V;
    cin >> V;
    cout << solution(V);
    return 0;
}