#include <iostream>

using namespace std;

int main()
{
    long long v;
    cin>>v;
    int br=0;
    int br1=0;
    while(v>0){
            br1=v%10;
            br=br+(br1/5);
            br1=br1%5;
            br=br+(br1/2);
            br1=br1%2;
            br=br+br1;
            v=v/10;
    }
    cout<<br;
    return 0;
}