#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<vector>
#define rg register
template<typename T>void read(rg T &x){
	x=0;rg int fh=1;
	rg char ch=getchar();
	while(ch<'0' || ch>'9'){
		if(ch=='-') fh=-1;
		ch=getchar();
	}
	while(ch>='0' && ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	x*=fh;
}
long long n,ans;
int main(){
	read(n);
	rg long long now=1;
	rg int cnt=0,num=0;
	while(1){
		if(n>=now*10-1){
			ans+=1LL*num*(now*10-now);
		} else {
			ans+=1LL*num*(n-now+1);
			break;
		}
		cnt++;
		now*=10;
		if(cnt%3==0) num++;
	}
	printf("%lld\n",ans);
	return 0;
}

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=double;
using vll=vector<ll>;
using vvll=vector<vector<ll>>;
#define FOR(i,a,b) for(ll i=a;i<(ll)b;++i)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define aa first
#define bb second
#define PB push_back
#define EQ(a,b) (fabs(a-b)<=(fabs(a+b)*EPS))
#define MOD ((ll)(1e9+7))
#define dbg cerr
#define out(n) cout << n << '\n'

//#define dbg if(0)cerr

int main(){
  ios::sync_with_stdio(0);cin.tie(0);
  vector<pair<ll,ll>> a = {{1e3 - 1, 0},{1e6 - 1, 1},{1e9 - 1, 2},{1e12 - 1, 3},{1e15 - 1,4},{1e18 - 1, 5}};
  ll n;
  cin>>n;
  ll res = 0;
  for (int i = 0; i < a.size(); ++ i) {
    res += min(a[i].aa,n) * a[i].bb;
    if (i > 0) res -= min(a[i-1].aa,n) * a[i].bb;
    if (a[i].aa > n) break;
  }
  out(res);

  return 0;
}
