#include<stdio.h>
int main()
{
	long v,brje,c,bp,o,bd,bj,k;
	scanf("%d",&v); 
	k=0;
	while(v>0){
		c=v%10;
		bp=c/5;
		o=c-bp*5;
		bd=o/2;
		o=o-bd*2;
		bj=o;
		v=v/10;
		k=k+bp+bd+bj;
	}
	
	printf("%d",k); 
	return 0;

}