#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long n, t, q, ans;
int main() {
  n = read();
  if (n == 2) {
    puts("1");
    return 0;
  }
  if (n == 3) {
    puts("3");
    return 0;
  }
  if (n == 4) {
    puts("6");
    return 0;
  }
  t = n;
  q = 1;
  while (t > 9) {
    t = t / 10;
    q *= 10;
  }
  if (t >= 5) {
    q *= 10;
    long long ans = n - (q - 1) / 2;
    if (q - 1 == n) ans -= 1;
    cout << ans;
    return 0;
  } else {
    ans = 0;
    long long k = q - 1;
    for (int i = 0; k <= n; i++) {
      ans += k / 2;
      k += q;
    }
    long long tt = 2 * n - 1;
    while (tt >= k) {
      ans += max(n - (k / 2), 0);
      k += q;
    }
  }
  cout << ans;
  return 0;
}
