#include <bits/stdc++.h>
using namespace std;
long long int n;
int main() {
  cin >> n;
  long long int summ = n + (n - 1);
  long long int wei = 0;
  while (summ != 0) {
    summ /= 10;
    wei++;
  }
  long long int stdl = 9;
  for (int i = 1; i < wei; i++) {
    stdl = stdl * 10 + 9;
  }
  summ = n + (n - 1);
  if (summ < stdl) wei--, stdl /= 10;
  long long int ans, p = stdl / 2;
  ans = min(p, n - p);
  long long int qian = 1;
  for (int i = 1; i <= wei; i++) qian *= 10;
  while (stdl + qian <= summ) {
    stdl += qian;
    p = stdl / 2;
    ans += min(p, n - p);
  }
  if (n < 5) {
    if (n == 2) ans = 1;
    if (n == 3) ans = 3;
    if (n == 4) ans = 6;
  }
  cout << ans;
}
