#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
int n;
void comp(long long ma) {
  int l, r;
  if (n >= ma) {
    l = 1;
    r = ma - 1;
  } else {
    r = n;
    l = ma - n;
  }
  ans += (r - l + 1) / 2;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  if (n < 5) return cout << n * (n - 1) / 2 << endl, 0;
  long long ma = n * 2;
  long long mask = 1;
  while (mask <= ma) mask *= 10;
  mask /= 10;
  ma = ma / mask * mask - 1;
  while (ma > 0) {
    comp(ma);
    ma -= mask;
  }
  cout << ans << endl;
  return 0;
}
