#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, h = 1, maxn = 9, ans = 0;
  scanf("%lld", &n);
  if (n < 5) {
    printf("%lld\n", n * (n - 1) / 2);
    return 0;
  }
  while (maxn * 10 + 9 <= 2 * n - 1) maxn = maxn * 10 + 9;
  while (h <= maxn) h *= 10;
  for (long long i = 0; i <= 9; i++) {
    ans += max(0ll, maxn / 2 - max(1ll, maxn - n) + 1);
    maxn += h;
  }
  printf("%lld\n", ans);
  return 0;
}
