#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long s = 2 * n - 1;
  if (s < 9) {
    cout << (n * (n - 1)) / 2 << endl;
    return 0;
  }
  long long mx = 9;
  long long pw = 10;
  while (mx <= s) {
    mx *= 10;
    mx += 9;
    pw *= 10;
  }
  mx /= 10;
  pw /= 10;
  long long res = 0;
  for (long long i = 0; i < 10; ++i) {
    long long curnum = i * pw + mx;
    if (curnum > s) {
      continue;
    }
    if (n >= curnum - 1) {
      res += curnum / 2;
    } else {
      res += n - curnum / 2;
    }
  }
  cout << res << endl;
  return 0;
}
