#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
inline long long FindDig(long long a) {
  long long res = 0;
  while (a > 0) {
    ++res;
    a /= 10;
  }
  return res;
}
inline bool Check(long long a) {
  while (a > 0) {
    if (a % 10 != 9) return false;
    a /= 10;
  }
  return true;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n;
  cin >> n;
  long long MAX = n * 2 - 1;
  if (Check(MAX)) {
    cout << 1;
    return 0;
  }
  long long dig = FindDig(MAX);
  const long long diff = pow(10, dig - 1);
  long long res = 0, cur = pow(10, dig - 1) - 1;
  while (cur <= MAX) {
    if (cur <= n + 1)
      res += (cur - 1) / 2;
    else
      res += (n * 2 - cur + 1) / 2;
    cur += diff;
  }
  cout << res;
}
