#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define si short int
#define vi vector<ll>
#define vii vector<vi>
#define ul unsigned ll

int main(void)
{
    ul v;
    cin>>v;
    ul pom=v;
    ll brc=0;
    while(pom>0)
    {
        ul x=pom%10;
        while(x>0)
        {
            if(x>=5) x-=5, brc++;
            else if(x>=2) x-=2, brc++;
            else x=0,brc++;
        }

        pom/=10; //da mi skrati jednu cifru
    }
    cout<<brc;
}