#include <bits/stdc++.h>
template <typename tp>
inline tp max(tp x, tp y) {
  return (x > y) ? x : y;
}
template <typename tp>
inline tp min(tp x, tp y) {
  return (x < y) ? x : y;
}
template <typename tp>
inline bool chkmax(tp& x, tp y) {
  return (x >= y) ? false : (x = y, true);
}
template <typename tp>
inline bool chkmin(tp& x, tp y) {
  return (x <= y) ? false : (x = y, true);
}
template <typename tp>
tp read(tp& in) {
  in = 0;
  char ch = getchar();
  tp f = 1;
  for (; ch > '9' || ch < '0'; ch = getchar())
    if (ch == '-') f = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) in = in * 10 + ch - '0';
  return in *= f;
}
long long n;
long long get_(long long n) {
  long long res = 0;
  while (n > 0) n /= 10, ++res;
  return res;
}
int main() {
  read(n);
  if (n < 5) return printf("%d\n", n * (n - 1) >> 1), 0;
  long long m = n + n - 1;
  long long k = get_(m);
  long long p = 1;
  for (int i = (1), ir = (k); i <= (ir); ++i) p *= 10;
  if (m != p - 1) --k, p /= 10;
  long long mm = m;
  while (mm > 10) mm /= 10;
  long long x = p - 1, ans = 0;
  for (int i = (0), ir = (mm); i <= (ir); ++i) {
    if (x - 1 <= n)
      ans += x / 2;
    else if (n - x / 2 > 0)
      ans += n - x / 2;
    x += p;
  }
  printf("%I64d\n", ans);
  return 0;
}
