#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;

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

	string n;
	cin >> n;
	ll count = 0;
	int len = n.length();
	size_t sz = 0;
	count = stoll(n, &sz, 10);
	int maxcom = (len - 1) / 3;

	ll x = 1;
	for (int i = 0; i < maxcom; i++) x *= 1000;
	count = count - x + 1;
	count *= maxcom;

	x = 1;
	for (int i = 0; i < maxcom; i++) {
		count += 999 * x * i;
		x *= 1000;
	}
	cout << count << '\n';

	return 0;
}
