#include <iostream>

using namespace std;

int main()
{
    long long v;
    cin>>v;
    int nov=0;
    int br1=0;
    while (v>0)
    {
        br1=v%10;
        nov=nov+(br1/5);
        br1=br1%5;
        nov=nov+(br1/2);
        br1=br1%2;
        nov=nov+br1;
        v=v/10;

    }

    cout<<nov;

    return 0;
}