#include<stdio.h>
unsigned long Jedinice(unsigned long n){
	unsigned long i,j=0;
	for(i=1;i<=n;i*=10){
		j=i;
	}
	return j;
	}
	unsigned long  Dvojke(unsigned long n){
		unsigned long i,d=0;
	for(i=2;i<=n;i*=10){
		d=i;
	}
	return d;
}
	unsigned long  Petice(unsigned long n){
		unsigned long i,p=0;
	for(i=5;i<=n;i*=10){
		p=i;
	}
	return p;
}
	unsigned long  Max(unsigned long  j,unsigned long  d,unsigned p){
		unsigned long max;
		max=j;
		if(j<d)max=d;
		if(j<p)max=p;
		return max;
	}
int main(){
	unsigned long n,max,br=0;
	scanf("%lu",&n);
  while(n>0){
   max= Max(Jedinice(n),Dvojke(n),Petice(n));
   n-=max;
   br++;
  }
  printf("%lu",br);
	return 0;
}