#include <iostream>

using namespace std;

int main()
{
    int k,br,brc;
    long long int v,vc,vkc;
    cin>>v;
    br = 0;
    brc = 0;
    vc = v;
    vkc = v;

    while(vc>0){
        vc = vc/10;
        brc++;
    }
    //cout<<"brc: "<<brc<<endl;
    //brc==broj cifara u v
    int V[brc];
    for(int i=brc; i>0; i--)
    {
        V[i] = vkc%10;
        vkc=vkc/10;
        //cout<<"V[i]:"<<V[i]<<endl;
    }

    //sada imamo svaku cifru sacuvanu od broja v
    //cout<<"brc: "<<brc<<endl;

    while(V[brc]>0){
        for(int j=1;j<=brc;j++){

            if(V[j]>=5){
                V[j]=V[j]-5;
                br++;
                //cout<<"usao u 1. if"<<endl;
            }
            if(V[j]==4){
                V[j]=V[j]-4;
                br=br+2;
                //cout<<"usao u 2. if"<<endl;
            }
            if(V[j]>=2){
                V[j]=V[j]-2;
                br++;
                //cout<<"usao u 3. if"<<endl;
            }
            if(V[j]==1){
                V[j]=V[j]-1;
                br++;
                //cout<<"usao u 4. if"<<endl;
            }
        }
    }
    cout<<br;
}