#include <iostream>
#include <math.h>
#include <bits/stdc++.h>

using namespace std;

int brojCifri(long long unsigned p)
{
    int cifre = 0;

    while(p != 0)
    {
        p = p / 10;
        cifre++;
    }

    return cifre;
}

int main()
{
    long long unsigned novac, x;
    int cifre, brojac = 0;
    cin >> novac;
    string s, s1, s2;

    do
    {
        cifre = brojCifri(novac);
        if(novac >= 5 * (pow(10.0, cifre - 1)))
        {
            brojac++;
            cout << "c:" << cifre << endl;
            x = 5 * (pow(10.0, cifre - 1));
            cout << novac << " " << x << endl;
            novac = novac - x;
            cout << novac << endl;
            continue;
        }

        if(novac >= 2 * (pow(10.0, cifre - 1)))
        {
            brojac++;
            x = 2 * (pow(10.0, cifre - 1));
            cout << novac << " " << x << endl;
            novac = novac - x;
            cout << novac << endl;
            continue;
        }

        if(novac >= 1 * (pow(10.0, cifre - 1)))
        {
            brojac++;
            x = pow(10.0, cifre - 1);
            cout << novac << " " << x << endl;
            novac = novac - x;
            cout << novac << endl;
            continue;
        }
    }
    while(novac > 0);

    cout << brojac;
    return 0;
}