#include <iostream>


using namespace std;

int main()
{
    int v, d, br = 0, cif;
    cin >> v;
    while(v > 0)
    {
        cif = v%10;
        while(cif>0)
            {
            if(cif-5>=0)
            {
                br++;
                cif -=5;
            }
            else{
                if(cif-2>=0){
                    br++;
                    cif-=2;
                }
                else{
                    if(cif-1>=0)
                    {
                        br++;
                        cif-=1;
                    }
                }
            }
        }
        v = v/10;
    }

cout << br <<endl;

    return 0;
}