#include <bits/stdc++.h>
using namespace std;
long long n, ans;
long long check(long long nin) {
  long long tmp = 1, tmp2, tmp3, l, r, res = 0;
  for (int i = 1; i <= nin; i++) tmp *= 10;
  tmp2 = tmp, tmp--;
  l = max((long long)1, tmp - n), r = min(n, tmp);
  if (l <= r) res += (r - l + 1) / 2;
  tmp3 = tmp2;
  for (int i = 1; i < 9; i++) {
    long long cur = tmp3 + tmp;
    l = max((long long)1, cur - n), r = min(n, cur);
    if (l <= r) res += (r - l + 1) / 2;
    tmp3 += tmp2;
  }
  return res;
}
int main() {
  cin >> n;
  for (int i = 11; i > 0; i--) {
    if (check(i)) return cout << check(i) << "\n", 0;
  }
  cout << n * (n - 1) / 2 << "\n";
  return 0;
}
