#include <iostream>
using namespase std;
int main()
{
    cin>>V;
    int z=0 ;
    while(V>0);
    { k=V%10;
    int p=k/5;
    int m=(k%5)/2;
    int l=k-p-m;
    int z=z+p+l+m;
    V=V/10;
    }
cout<<z<<endl;
   return 0;
}