#include <iostream>


using namespace std;
int main()
{
long long n,x,k;
cin>>n;
k=0;
x=n;

while(x!=0){
  n=n%10;
  while(n!=0){


  if(n>=5){
    n=n-5;
    k=k+1;
  }
  else if (n>=2){
    n=n-2;
    k=k+1; 
  }
  else if(n==1){
    n=n-1;
    k=k+1;
  }
  }
x=x/10;
n=x;
}
cout<<k<<"\n";
}