#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, val = 0, p;
  cin >> n;
  p = 1;
  for (long long i = 2 * n; i >= 10; i /= 10) p *= 10;
  for (long long int i = p - 1; i < 2 * n; i += p) {
    if (i <= n)
      val += i / 2;
    else
      val += n - i / 2;
  }
  if (n >= 5)
    cout << val;
  else
    cout << n * (n - 1) / 2;
  return 0;
}
