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