#include <bits/stdc++.h>
using namespace std;
string inttostr(int n) {
  stringstream rr;
  rr << n;
  return rr.str();
}
int main() {
  long long n, i, j, k, beg, mx9, lim, ans = 0;
  cin >> n;
  mx9 = 0;
  i = 5;
  if (n < 5) {
    cout << n * (n - 1) / 2 << "\n";
    return 0;
  }
  while (i <= n) {
    mx9++;
    i *= 10;
  }
  lim = i / 5;
  beg = lim - 1;
  for (i = 0; i < 9; i++) {
    k = i * lim + beg;
    if (k > n) {
      if (k > 2 * n) break;
      ans += (n - k + n + 2) / 2;
    } else
      ans += k / 2;
  }
  cout << ans << "\n";
  return 0;
}
