#include <bits/stdc++.h>
using namespace std;
long long base[15];
void init() {
  base[0] = 1;
  for (int i = 1; i < 15; i++) base[i] = base[i - 1] * 10;
}
int length(int n) {
  int len = 0;
  while (n) {
    n /= 10;
    len++;
  }
  return len;
}
int max_number_of_nine(int n) {
  int len = length(n);
  if (base[len] - 1 != n)
    return len - 1;
  else
    return len;
}
long long cal(int n, int len) {
  long long ret = 0;
  long long val;
  for (int i = 0; i < 9; i++) {
    if ((val = (i + 1) * base[len] - 1) < 2 * n) {
      if (val - 1 > 1 && val - 1 <= n) {
        ret = ret + (val - 1) / 2;
      } else if (val - n > 0 && val - n < n) {
        ret = ret + (n - val + n + 1) / 2;
      }
    } else
      break;
  }
  return ret;
}
int main() {
  int n;
  init();
  while (cin >> n) {
    cout << cal(n, max_number_of_nine(2 * n - 1)) << endl;
  }
  return 0;
}
