//#pragma GCC optimize(2)
#include<bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(false);cin.tie(nullptr)
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define lc(x) ((x)<<1)
#define rc(x) (((x)<<1)|1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
 
const ll LINF=1e18;
const ll MOD=1e9+7;
const int INF=0x3f3f3f3f;
const int MAXM=500050;
const int MAXN=200050;


void mainwork(int T){
	ll n;
	scanf("%lld",&n);
	ll ans=0;
	if(n<1000){
		puts("0");
		return;
	}
	if(n<1000000){
		ans+=(n-1000+1);
		printf("%lld",ans);
		return;
	}else{
		ans+=(999999-1000+1);
	}
	if(n<1000000000){
		ans+=(n-1000000+1)*2;
		printf("%lld",ans);
		return;
	}else{
		ans+=(999999999-1000000+1)*2;
	}
	if(n<1000000000000ll){
		ans+=(n-1000000000ll+1)*3;
		printf("%lld",ans);
		return;
	}else{
		ans+=(1000000000000ll-1000000000ll)*3;
	}
	ans+=(n-1000000000000ll+1)*4;
	if(n== 1000000000000000ll)ans++;
	printf("%lld",ans);
	return;
}
signed main(){
	//IOS;
	#ifndef ONLINE_JUDGE
	//freopen("./in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	#endif
	int t=1;
	//scanf("%d",&t);
	//prework();
	for(int i=1;i<=t;i++){
		mainwork(i);
	}
}
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pb push_back
#define sz(x) (int)x.size()
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define F first
#define S second
#define watch(x) cerr << "\n" << (#x) << " = " << (x) << "\n"
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	ll n;
	cin >> n;
	int len = to_string(n).length();
	ll ans = 0;
	for(int i = 1; i < len; ++i){
		ans += (9 * pow(10, i - 1)) * ((i - 1) / 3);
	}
	ans += ((n + 1 - pow(10, len - 1)) * ((len - 1) / 3));
	cout << ans;
	return 0;
}