#include <iostream>

//#define DEBUG

using namespace std;

typedef unsigned long long ull;

int main()
{
    ull curency[3*18];
    curency[0] = 1;
    curency[1] = 2;
    curency[2] = 5;
    for(int i = 3; i < 3*18; ++i){
        curency[i] = curency[i-3]*10;
    }
    ull val;
    cin >> val;
    int c = 3*18-1;
    int res = 0;
    while(val != 0){
#ifdef DEBUG
        cout << "val = " << val << endl;
#endif // DEBUG
        if(val >= curency[c]){
            val -= curency[c];
            ++res;
        }
        else{
            --c;
        }
    }
    cout << res << endl;
    return 0;
}