#include <bits/stdc++.h>
#pragma warning(disable : 4996)
const long long MOD = 1000000007;
const int maxn = 3e8 + 5;
const double Inf = 10000.0;
const double PI = acos(-1.0);
using namespace std;
long long mul(long long a, long long b, long long m) {
  long long res = 0;
  while (b) {
    if (b & 1) res = (res + a) % m;
    a = (a + a) % m;
    b >>= 1;
  }
  return res % m;
}
long long quickPower(long long a, long long b, long long m) {
  long long base = a;
  long long ans = 1ll;
  while (b) {
    if (b & 1) ans = mul(ans, base, m);
    base = mul(base, base, m);
    b >>= 1;
  }
  return ans;
}
int readint() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
long long readll() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
void Put(long long x) {
  if (x > 9) Put(x / 10);
  putchar(x % 10 + '0');
}
int main() {
  long long n;
  n = readll();
  if (n < 5) {
    Put(n * (n - 1) / 2);
    return 0;
  }
  long long tmp = 1ll;
  int len;
  for (int i = 1;; i++) {
    tmp *= 10;
    if (5 * tmp > n) {
      len = i;
      break;
    }
  }
  long long pow = 1;
  long long num = 0;
  long long ans = 0;
  for (int i = 0; i < len; i++) {
    num = num * 10 + 9;
    pow *= 10;
  }
  for (int i = 0; i < 9; i++) {
    long long r = i * pow + num;
    if (r > 2 * n - 1)
      break;
    else if (r < n + 1ll)
      ans += r / 2;
    else if (r < 2 * n)
      ans += (2 * n - r + 1) / 2;
  }
  Put(ans);
}
