#include <bits/stdc++.h>
using namespace std;
long long int noDigits(long long int x) {
  long long int res = 0;
  while (x) {
    x /= 10;
    res++;
  }
  return res;
}
bool allNines(long long int x) {
  while (x) {
    long long int d = x % 10;
    if (d != 9) return false;
    x /= 10;
  }
  return true;
}
int main() {
  long long int n;
  scanf("%lld", &n);
  long long int maxN = n + n - 1;
  if (maxN < 9) {
    printf("%lld\n", n * (n - 1) / 2);
  } else if (allNines(maxN)) {
    printf("%lld\n", 1LL);
  } else {
    long long int ans = 0;
    long long int noNines = noDigits(maxN) - 1;
    long long int num = (long long int)pow(10, noNines) - 1;
    while (num <= maxN) {
      if (n >= num)
        ans += num / 2;
      else
        ans += (n - num / 2);
      num += (long long int)pow(10, noNines);
    }
    printf("%lld\n", ans);
  }
  return 0;
}
