#include <bits/stdc++.h>
using namespace std;
long long power(long long _a, long long _b) {
  long long _r = 1;
  while (_b) {
    if (_b % 2 == 1) _r = (_r * _a);
    _b /= 2;
    _a = (_a * _a);
  }
  return _r;
}
long long solve(long long n, long long u) {
  if ((u + 1) / 2 <= n) {
    if ((u + 1) / 2 == n)
      return 1;
    else {
      if (n == u)
        return n - ((u + 1) / 2);
      else
        return n - ((u + 1) / 2) + 1;
    }
  }
  return 0;
}
int main() {
  long long n, i;
  cin >> n;
  long long len = 0, temp = n, t = 0, ans = 0;
  vector<long long> a;
  while (temp) {
    len++;
    a.push_back(temp % 10);
    temp = temp / 10;
  }
  if (n <= 4) {
    cout << (n * (n - 1)) / 2;
    return 0;
  }
  if (a[a.size() - 1] >= 5) {
    long long u = power(10, len);
    ans = solve(n, u - 1);
    cout << ans;
  } else {
    long long k = power(10, len - 1);
    long long r = k;
    while ((k / 2) <= n) {
      if (n >= k - 1)
        ans += solve(k - 1, k - 1);
      else
        ans += solve(n, k - 1);
      k += r;
    }
    cout << ans;
  }
  return 0;
}
