#include <iostream>

using namespace std;

int main()
{
    long int n;
    cin >> n;
    int uk = 0;
    while(n > 0)
    {
        int c = n%10;
        if(c >= 5)
        {
            c -= 5;
            uk++;
        }
        if(c >= 2)
        {
            c -= 2;
            uk++;
        }
        if(c >= 2)
        {
            c -= 2;
            uk++;
        }
        if(c >= 1)
        {
            c -= 1;
            uk++;
        }
        n = n /10;
    }

    cout << uk;

}