#include <bits/stdc++.h>
#define INT long long int
#define oo 987654321
using namespace std;
INT T, n, a[10], m, p = 1, b[10], cnt, ans;
INT c[10] = {6,2,5,5,4,5,6,3,7,6};
int main()
{
    ios::sync_with_stdio(false);
for( int no = 11 ; no <= 20 ; no++ )
{
    char in[110], out[110];
    sprintf(in, ".%d.in", no);
    freopen(in, "w", stdout);
    cin>>n;
    cout<<n<<endl;
    for(int i = 0 ; i < 10 ; i++ ) a[i] = b[i] = 0;
    p = 1, cnt = 0, ans = 0, m = 0;
    for( p = 1 ; p < min(n+1, 100000ll) ; p++ )
    {
        INT x = p;
        while(x) b[x%10]++, x/=10;
    }
    if( n >= 100000 ) b[0] += 5, b[1]++;
    for( ; p+100000 <= n ; p+=100000 )
    {
        cnt*=10;
        INT x = p, y = p;
        for(int j = 0 ; j < 10 ; j++ )
            b[j]+=50000;
        x/=100000;
        while( x ) b[x%10]+=99999, x/=10;
        y/=100000; y++;
        while( y ) b[y%10]++, y/=10;
    }
    for( p++ ; p <= n ; p++ )
    {
        INT x = p;
        while(x) b[x%10]++, x/=10;
    }
    for(int i = 0 ; i < 10 ; i++ )
        ans += b[i]*c[i];
    sprintf(out, ".%d.out", no);
    freopen(out,"w",stdout);
    cout<<ans<<endl;
}
}
