#include <bits/stdc++.h>
using namespace std;
long long int arr[11];
void set_nine() {
  arr[0] = 0;
  arr[1] = 9;
  arr[2] = 99;
  arr[3] = 999;
  arr[4] = 9999;
  arr[5] = 99999;
  arr[6] = 999999;
  arr[7] = 9999999;
  arr[8] = 99999999;
  arr[9] = 999999999;
  arr[10] = 99999999999999999;
}
long long int calculate_nine(long long int m) {
  int in;
  for (int i = 0; i < 11; i++) {
    if (m >= arr[i])
      in = i;
    else
      return in;
  }
  return in;
}
int main() {
  long long int i, j, k, m, n, c = 0, in, num, add;
  cin >> n;
  set_nine();
  m = 2 * n - 1;
  in = calculate_nine(m);
  add = pow(10, in);
  num = add - 1;
  if (m < 9) {
    m = (n * (n - 1)) / 2;
    return cout << m, 0;
  }
  while (n >= num) {
    c = c + num / 2;
    num = num + add;
  }
  while (m >= num) {
    c = c + (2 * n - num) / 2 + 1;
    num = num + add;
  }
  cout << c;
  return 0;
}
