#include <bits/stdc++.h>
using namespace std;
long long n, res;
long long x[9];
int main() {
  scanf("%lld", &n);
  x[0] = 5;
  for (long long i = 1; i < 9; i++) x[i] = x[i - 1] * 10;
  long long st = -1;
  for (long long i = 8; i >= 0; i--) {
    if (n >= x[i]) {
      st = x[i];
      break;
    }
  }
  if (st == -1) {
    printf("%lld\n", (n * (n - 1)) / 2);
    return 0;
  }
  long long ts = st * 2;
  long long curr = ts - 1;
  long long idx = st;
  long long base = 1;
  for (long long i = st; i + ts - 1 <= n; i += ts) {
    res += curr;
    curr += ts;
    idx += ts;
    base++;
  }
  res += base * (n - idx + 1);
  long long diff = idx + st - 1;
  if (diff <= n) res--;
  printf("%lld\n", res);
}
