#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    int m,l,o=0,c;
    int b[100];
    long long int n,k;
    cin>>n;

    while(k>0){
        int i=0;
        k=n;
        while(n>0){
            int c = n%10;
            n /= 10;
            b[i]=c;
            i++;

        }
        if(b[i-1]>=1 && b[i-1] < 2)
        {
            m=1;
        }
        if(b[i-1]>=2 && b[i-1]<5){
            m=2;
        }
        if(b[i-1]>=5){
            m=5;
        }

        o++;
        n=k-pow(10,i-1)*m;
    }
   cout<<o-1;

}