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