#include <bits/stdc++.h>

using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long a;
    cin>>a;
    int ds;
    int res=0;
    for(int i =19;i>=0;i--){
    	ds=(int)(a/pow(10,i))%10;
    	//if(ds<=0){break;}
    
    	while(ds>=5){ds-=5;res++;}
    	while(ds>=2){ds-=2;res++;}
    	while(ds>=1){ds-=1;res++;}
    		
	}
	cout<<res;
	return 0;
}