#include <bits/stdc++.h>

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long n;
    cin>>n;
    long long bc = (long long)(floor(log10(n)) + 1);
    long long s=0;
    while(n>0)
    {

        if(n>=5*pow(10,bc-1))
        {
            n-=5*pow(10,bc-1);
            s++;
        }
        else if(n>=2*pow(10,bc-1))
        {
            n-=2*pow(10,bc-1);
            s++;
        }
        else if(n>=pow(10,bc-1))
        {
            n-=pow(10,bc-1);
            s++;
        }
        cout<<bc<<" "<<n<<"\n";
        bc=(long long)(floor(log10(n)) + 1);
    }
    cout<<s;
}