#include <bits/stdc++.h>
using namespace std;
long long n;
long long A[10] = {0,     9,      99,      999,      9999,
                   99999, 999999, 9999999, 99999999, 999999999};
long long get_d() {
  long long ms = n + n - 1;
  for (int i = 0; i < 10; ++i) {
    if (A[i] > ms) return A[i - 1];
  }
  return A[9];
}
int main() {
  while (cin >> n) {
    if (n == 2) {
      cout << 1 << endl;
      continue;
    } else if (n == 3) {
      cout << 3 << endl;
      continue;
    } else if (n == 4) {
      cout << 6 << endl;
      continue;
    }
    long long d = get_d();
    long long res = 0;
    for (int i = 0;; ++i) {
      long long t = d + i * d + i;
      if (n + n - 1 < t) break;
      if (n >= t)
        res += (t >> 1);
      else if (n - (t >> 1) > 0)
        res += n - (t >> 1);
    }
    cout << res << endl;
  }
  return 0;
}
