#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int col(int n) {
  int res = 0;
  while (n) {
    if (n % 10 == 9) res++;
    n /= 10;
  }
  return res;
}
int main() {
  long long ans = 0, n;
  cin >> n;
  if (n <= 4) {
    cout << (n - 1) * n / 2;
    return 0;
  }
  long long a = 9, p = 10;
  while (a * 10 + 9 <= n + n - 1) a = a * 10 + 9, p *= 10;
  for (long long i = 0; i < 10; i++) {
    long long num = p * i + a;
    if (num > n + n - 1) break;
    if (col(num) == col(a)) {
      ans += min(n - num / 2, num / 2);
    }
  }
  cout << ans;
  return 0;
}
