#include <bits/stdc++.h>
using namespace std;
long long n, five = 5, ans, k, ten[20];
int main() {
  cin >> n;
  int i;
  if (n < 5) {
    cout << n * (n - 1) / 2;
    return 0;
  }
  for (i = 0;; i++, five *= 10)
    if (five > n) {
      k = i;
      break;
    }
  ten[0] = 1;
  for (i = 1; i <= 15; i++) ten[i] = ten[i - 1] * 10;
  for (i = 0; i <= 8; i++) {
    long long num = ten[k] * (1 + i) - 1;
    long long mid = (ten[k] * (1 + i) - 1) >> 1;
    if (mid >= n) break;
    ans += min(n * 1ll, num - 1) - mid;
  }
  cout << ans;
  return 0;
}
