#include <iostream>

using namespace std;

int main()
{
    unsigned long long int v;
    int c=0;
    int c1, c2, c3;
    int x;

    cin >> v;

    while(v>0)
    {
        x = v % 10;
        c1 = x / 5;
        c2 = (x%5) / 2;
        c3 = (x%5%2) / 1;
        c += c1 + c2 + c3;
        v /= 10;
    }
    
    cout << c;
    return 0;
}