#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  if (n <= 4) {
    if (n == 2) {
      printf("1");
    }
    if (n == 3) {
      printf("3");
    }
    if (n == 4) {
      printf("6");
    }
    return 0;
  }
  int x = n;
  int digit = 0;
  while (x >= 10) {
    x /= 10;
    digit++;
  }
  if (x >= 5) {
    digit++;
  }
  int pair = 0;
  for (int i = 0; i < digit; i++) {
    pair *= 10;
    pair += 9;
  }
  int ans = 0;
  int cnt = 1;
  int div = (pair + 1) / 2;
  int inter = n - (div - 1);
  while (inter >= (pair + 1)) {
    ans += cnt * (pair + 1);
    cnt++;
    inter -= (pair + 1);
  }
  ans += inter * cnt;
  ans -= (n + 1) / (pair + 1);
  printf("%d", ans);
  return 0;
}
