#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, a = 0, x, b, t = 0, s, t1 = 0;
  cin >> n;
  x = 2 * n - 1;
  s = powl(10, a) - 1;
  for (; x >= s; a++) {
    s = powl(10, a) - 1;
  }
  a = a - 2;
  b = powl(10, a);
  b--;
  if (b == 0)
    t1 = (n * (n - 1)) / 2;
  else {
    for (; b < (powl(10, a + 1) - 1);) {
      if (n < b) {
        t = t + (b / 2) - (b - 1 - n);
        if (t < t1) break;
      } else {
        t += b / 2;
      }
      t1 = t;
      b += powl(10, a);
    }
  }
  cout << t1;
}
