#include <iostream>
#include <cmath>
using namespace std;
 int main()
 {
	 unsigned long long v, rez=0;
	 cin>>v;
	 double i=17;
	 while(i>=0)
	 {
		 rez=rez+(v%((int)(pow(10.0, i+1))))/(5*((int)pow(10.0, i)));
		 rez=rez+(v%(5*((int)pow(10.0, i))))/(2*((int)pow(10.0, i)));
		 rez=rez+(v%(2*(int)pow(10.0, i)))/((int)pow(10.0, i));
		 i--;
	 }
	 
	 cout<<rez;
	 
  
     return 0;
 }