#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long n, cnt[10], ans = 0, d, g;
  int i = -1;
  cin >> n;
  d = (n * 2);
  while (d > 0) {
    d /= 10;
    i++;
  }
  d = 1;
  for (i = i; i > 0; i--) {
    d *= 10;
  }
  if (d == 1) {
    ans = n * (n - 1) / 2;
    cout << ans << endl;
    return 0;
  }
  for (i = 1; i < 10; i++) {
    g = d * i;
    g -= 2;
    ans += max(min(g, n) - (g / 2), 0ll);
  }
  cout << ans << endl;
  return 0;
}
