#include <bits/stdc++.h>
using namespace std;
const long long mINF = 1000 * 1000 * 1000 + 9;
const double ebs = 0.000001;
long long h(long long bin) {
  long long answ = 0;
  while (bin > 0) {
    answ++;
    bin /= 10;
  }
  return answ;
}
bool ch(long long bin) {
  while (bin > 0) {
    if (bin % 10 != 9) return false;
    bin /= 10;
  }
  return true;
}
int main() {
  long long kol_vo;
  cin >> kol_vo;
  long long test = kol_vo + kol_vo - 1;
  long long nine = 0;
  for (int c = 0; c < h(kol_vo + kol_vo - 1) - 1; c++) {
    nine = nine * 10 + 9;
  }
  long long help = h(nine), t = 1, answ = 0;
  for (long long c = 0; c < help; c++) t *= 10;
  if (kol_vo <= 4) {
    cout << (kol_vo - 1) * kol_vo / 2;
    return 0;
  }
  if (ch(test)) {
    cout << 1;
    return 0;
  } else {
    for (long long c = 0; c <= 8; c++) {
      long long now = nine;
      now += c * t;
      if (now < kol_vo + 1)
        answ += now / 2;
      else {
        if (now > kol_vo + kol_vo - 1)
          continue;
        else
          answ += (kol_vo - (now - kol_vo)) / 2 + 1;
      }
    }
  }
  cout << answ;
  return 0;
}
