#include <bits/stdc++.h>
using namespace std;
inline int maxim(int a, int b) {
  if (a < b) a = b;
  return a;
}
int main() {
  int n;
  long long m = 0, p = 1, ans = 0;
  scanf("%d", &n);
  while (m <= 2 * n - 1) {
    m = m * 10 + 9;
    p *= 10;
  }
  m /= 10;
  p /= 10;
  for (int i = 0; i <= 8; i++) {
    long long k = (p * i + m) / 2 - ((p * i + m) % 2 == 0 && (p * i + m) != 0) -
                  (maxim(1, p * i + m - n) - 1);
    if (k >= 0)
      ans += k;
    else
      i = 8;
  }
  printf("%I64d", ans);
  return 0;
}
