#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
long double eps = 1e-9;
long long pp = 1000000007;
long long mo(long long a, long long pp) {
  if (a >= 0 && a < pp) return a;
  a %= pp;
  if (a < 0) a += pp;
  return a;
}
long long powmod(long long a, long long b, long long pp) {
  long long ans = 1;
  for (; b; b >>= 1, a = mo(a * a, pp))
    if (b & 1) ans = mo(ans * a, pp);
  return ans;
}
void fre() {
  freopen("c://test//input.in", "r", stdin);
  freopen("c://test//output.out", "w", stdout);
}
int dx[5] = {0, -1, 1, 0, 0}, dy[5] = {0, 0, 0, -1, 1};
long long read() {
  long long ans = 0;
  char last = ' ', ch = getchar();
  while (ch < '0' || ch > '9') last = ch, ch = getchar();
  while (ch >= '0' && ch <= '9') ans = ans * 10 + ch - '0', ch = getchar();
  if (last == '-') ans = -ans;
  return ans;
}
long long n, dit, ans;
long long calc(long long x) {
  long long l = x - n, r = n;
  if (l > n) return 0;
  if (l <= 0) {
    l = 1, r = x - l;
    return r / 2;
  } else {
    return (r - l + 1) / 2;
  }
}
int main() {
  scanf("%lld", &n);
  long long x = n * 2, dit = 0;
  while (x) {
    dit++;
    x /= 10;
  }
  if (n <= 4) {
    cout << n * (n - 1) / 2;
    return 0;
  }
  long long base = 0, base10 = 1;
  for (long long i = 1; i <= dit - 1; i++)
    base = base * 10 + 9, base10 = base10 * 10;
  for (long long i = 0; i <= 8; i++) ans += calc(i * base10 + base);
  cout << ans;
  return 0;
}
