#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  scanf("%lld", &n);
  ;
  long long chk = 2 * n - 1, abhi = 0, shek = 0;
  long long hehe = chk;
  while (hehe) {
    if (hehe % 10 == 9) abhi++;
    shek++;
    hehe /= 10;
  }
  if (abhi == shek) return 0 * printf("1");
  if (n < 5) return 0 * printf("%lld", n * (n - 1) / 2);
  long long nines = shek - 1;
  long long res = 0, now = pow(10, nines) - 1;
  while (now <= chk) {
    if (now <= n * 1LL)
      res += now / 2LL;
    else {
      int chk = (now + 1) / 2;
      res += n - chk + 1LL;
    }
    now += pow(10, nines);
  }
  printf("%lld", res);
}
