#include <bits/stdc++.h>
using namespace std;
#include <algorithm>
#define ll long long int
#define pb push_back
#define fo(i, n) for (int i = 0; i < n; i++)
#define vct vector<long long int>
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll ans =0;
    if(n>=1000) ans = ans + n-999;
    if(n>=1000000) ans = ans + n-999999;
   
    if(n>=1000000000) ans = ans + n-999999999;
   
    if(n>=1000000000000) ans = ans + n-999999999999;

    if(n>=1000000000000000) ans = ans + n-999999999999999;
    cout<<ans<<endl;
    
    return 0;
}
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>
#include <random>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 61;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[201][12];

void cmemoInit(){
    rep(i, 201){
        rep(j, 12){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
template<class T> T fastpow(T a, T b){
    T res = 1;
    while(b > 0){
        if(b & 1){
            res *= a;
        }
        a *= a;
        b >>= 1;
    }
    return res;
}
int main(void){
    ll n;
    cin >> n;

    string s = to_string(n);
    ll ans = 0;
    rep(i, s.size() - 1){
        ans += fastpow(10LL, (ll)i) * 9 * (i / 3);
    }


    ans += fastpow(10LL, (ll)s.size() - 1) * (ll)(s[0] - '0' - 1) * (ll)((s.size() - 1) / 3);
    ll now = s[0] - '0';
    ll cnt = s.size() - 1;
    while(cnt--) now *= 10;
    now--;
    ans += (n - now) * (ll)((s.size() - 1) / 3);

    cout << ans << endl;

    // ll ans2 = 0;
    // for(ll i = 1; i <= n; i++){
    //     string ss = to_string(i);
    //     ans2 += (ss.size() - 1) / 3;
    // }
    // cout << ans2 << endl;


}