#include <bits/stdc++.h>

using namespace std;
long long int stepen(long long int a , long long int b );
int main(){

  long long  int n, br = 0, v;
  int  brn =  0;
    cin >>n;
    v = n;
   long long int a = 1,b = 2,c = 5;
    while(n >0){
        n/=10;
        brn++;
    }
    n  =  v;
    c = stepen(c, brn);
    b = stepen(b, brn);
    a = stepen(a, brn);
    while(n > 0 ){

        br+= n /c;
        n = n % c;

        br += n /b;
        n = n %b;

        br += n /a;
        n  = n % a;
        c/=10;
        a/=10;
        b/= 10;
    }
    cout << br;
    return 0;
}
long long int stepen(long long int a , long long int b){
    while(b > 0){
        a*=10;
    b--;}
    return a;
}