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

int main()
{
    string s;
    cin >> s;
    int rez = 0;

    for (unsigned int i = 0; i < s.size()-1; i++)
    {
        int a = s[i]-'0';

        if (a == 0) continue;
        if (a >= 5)
        {
            a %= 5;
            rez++;
        }
        if (a >= 2)
        {
            rez += a/2;
            a %= 2;
        }
        if (a >= 1)
        {
            rez += a;
        }
    }

    int a = s[s.size()-1]-'0';

    if (a == 0)
    {
        cout << rez << endl;
        return 0;
    }
    if (a >= 5)
    {
        a %= 5;
        rez++;
    }
    if (a >= 2)
    {
        rez += a/2;
        a %= 2;
    }
    if (a >= 1)
    {
        rez += a;
    }

    cout << rez << endl;

    return 0;
}