#include <stdio.h>
using namespace std;
int digits(int x){
  int br=0;
  while(x>0){
    br++;
    x=x/10;
  }
  return br;
 }
int number(int x){
    int br=0;
    while(x>=5){
        x = x - 5;
        br++;
    }
    while(x>=2){
        x = x - 2;
        br++;
    }
    if(x!=0)
     br++;
    return br;
}
int main(){
   long x;
   scanf("%ld",&x);
   int broj = digits(x);
   int i=broj-1;
   int arr[broj];
   int br=0;
   while(x>0){
        arr[i] = x%10;
        br+=number(arr[i]);
        x = x / 10;
        i--;
    }
   printf("%d",br);
 }