#include<bits/stdc++.h>
using namespace std;

int main(){
	int index = 0;
	long long n,count = 0;
	cin>>n;
	long long tem = n;
	while(n>0){
		index++;
		n/=1000; 
	}
	long long base = 1;
	for (int i=1;i<index;i++) base *=1000;
	base--;
	count = (tem-base)*(index-1);
	switch (index){
		case 1:case 2: break;
		case 3: count += 999000; break;
		case 4:count += 999000+999000000*2; break;
		case 5:count += 999000+999000000*2+999000000000*3; break;
		case 6: count += 999000+999000000*2+999000000000*3+999000000000000*4; break;
	}
	cout<<count;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

int main() {
  long long n; cin >> n;
  int n_digits = to_string(n).size();
  long long ans = 0;
  for (int d = 1; d < n_digits; d++) {
    ans += (d - 1) / 3 * 9 * pow(10, d - 1);
  }
  ans += (n_digits - 1) / 3 * (n - pow(10, n_digits - 1) + 1);
  cout << ans << endl;
}