#include <iostream>
using namespace std;
int main(){
  int s=0;
  int k=0;
  long long V;
  cin>>V;
  while(V>0){
      k=V%10;
      s+=k/5;
      k%=5;
      s+=k/2;
      k%=2;;
      s+=k;
      V/=10;
      }
      cout<<s;
}