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