#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  long long n;
  cin >> n;
  if (n <= 4) {
    cout << (n * (n - 1)) / 2 << '\n';
    return 0;
  }
  long long mx = n + n - 1, ans = 0;
  string s = to_string(mx);
  string sn = to_string(n);
  if (s == string((long long)s.size(), '9')) {
    cout << 1 << '\n';
  } else {
    for (long long i = 0; i <= 8; i++) {
      string t =
          string(1, char(i + '0')) + string((long long)s.size() - 1, '9');
      if (t > s) break;
      if (stoll(t) > stoll(sn)) {
        long long dist = stoll(t) - n;
        ans += (n - dist + 1) / 2;
      } else if (stoll(t) <= stoll(sn)) {
        ans += (stoll(t) - 1) / 2;
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
