#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
constexpr int INF = 1001001001;

constexpr bool is_multiple = false;

i64 count_between(i64 a, i64 b) {
    return b - a + 1;
}

void solve() {
    i64 n;
    cin >> n;

    i64 res = 0;

    i64 base = 1000;
    i64 cnt = 1;
    while (base <= n) {
        res += cnt * count_between(base, min(base*1000 - 1, n));
        base *= 1000;
        cnt++;
    }

    cout << res << endl;
}

int main() {
    int t = 1;
    if (is_multiple) cin >> t;
    while (t--) solve();
    return 0;
}

#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll n;

int main(void){
	scanf("%lld",&n);
	ll ans=0;
	ll rest=n;
	int dig=1;
	ll now=9;
	ll su=0;
	while(rest>0LL){
		if(rest>=now){
			ans+=now*((dig-1)/3LL);
			rest-=now;
		}else{
			ans+=rest*((dig-1)/3LL);
			rest=0;
		}
		dig++;
		now*=10LL;
	}
	printf("%lld\n",ans);
	return 0;
}
