#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n;cin>>n;
    ll ans=0;
    if(n>=1000)
    ans+=n-999;
    if(n>=1000000)
    ans+=n-999999;
    if(n>=1000000000)
    ans+=n-999999999;
    if(n>=1000000000000)
    ans+=n-999999999999;
    if(n>=1000000000000000)
    ans+=n-999999999999999;
    cout<<ans<<endl;
    

        }
#include <bits/stdc++.h>
#include <string>
#include <cmath>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define Messi                \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
#define pii pair<ll, ll>
#define mod 1000000007
#define vi vector<ll>
#define vii vector<pii>
#define all(v) v.begin(), v.end()
#define mi map<ll, ll>
//Never Let U Go!!

int main()
{
    Messi;
        ll n;
        cin >> n;
        ll a[5], b[17]={0};
        b[0] = 0;
        b[1] = 9;
        ll prev = b[1];
        for (ll i = 2; i <= 16; i++)
        {
            b[i] += ((prev * 10) + b[i - 1]);
            prev = prev * 10;
        } 
        ll num = n, dig = 0;
        while (num > 0)
        {
            dig++;
            num /= 10;
        }
        if (dig < 4)
        {
            cout << "0\n";
            return 0;
        }
        ll cnt=1,k=0,ans=0;
        for (ll i = 4; i < dig; i++)
        {
            if(k%3==0)
            {
                ans+=cnt*(b[i]-b[i-1]);
                k++;
            }
            else if(k%3==1)
            {
                ans+=cnt*(b[i]-b[i-1]);
                k++;
            }
            else if(k%3==2)
            {
                ans+=cnt*(b[i]-b[i-1]);
                cnt++;
                k=0;
            }
        }
        cout<< ans + (n-b[dig-1])*cnt;
  
    return 0;
}