#include <bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000000000005

using namespace std;

int main (){
	
	long long ans, n,i;
	cin>>n;
	i=1000;
	ans = 0;
	while (i<=n){
		ans += n-i+1;
		i=i*1000;
	}
	cout<<ans;
	return 0;
} 
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
template<class T> void chmax(T& a, T b){
    if(a < b){
        a = b;
    }
}
template<class T> void chmin(T& a, T b){
    if(a > b){
        a = b;
    }
}
int main()
{
    string n;

    cin >> n;

    int l = n.size();
    ll ans = 0;

    int com = l/3;

    if(l <= 3){
        ans = 0;
    }

    for(int i = 1; i <= 5; i++){
        if(l > i*3){
            if(l < (i+1)*3+1){
                ll N = stol(n);
                N -= pow(10,i*3) -1;

                ans += N*i;

                break;
            }
            else ans += (pow(10,(i+1)*3) - pow(10,i*3))*i;
        }
    }

    cout << ans << endl;
    return 0;
}