#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
const int M = 22;
const long long mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  long long s = 0;
  while (s * 10 + 9 <= n + n - 1) {
    s = s * 10 + 9;
  }
  if (s == n + n - 1) {
    cout << 1;
  } else {
    long long len = 1;
    while (len * 1ll * 10 <= 1ll * n + n - 1ll) {
      len *= 10;
    }
    long long i = s;
    long long ans = 0;
    for (; i <= n + n - 1; i += len) {
      if (i <= n + 1) {
        ans += (i - 1) / 2;
      } else {
        long long x = i - n;
        x = n - x + 1;
        ans += x / 2;
      }
    }
    cout << ans;
  }
}
