#include <bits/stdc++.h>
using namespace std;
long long n, i, tmp = 1, num, ans;
long long solve(long long x) {
  if (x > 2 * n - 1) {
    return 0;
  }
  long long m = min(n, x);
  long long a = x - m;
  if (a == 0) {
    a++;
    m--;
  }
  return (m - a) / 2 + 1;
}
int main() {
  cin >> n;
  while (tmp <= 2 * n) {
    tmp *= 10;
  }
  tmp /= 10;
  num = tmp - 1;
  if (num == 0) {
    return cout << n * (n - 1) / 2 << endl, 0;
  }
  for (i = 0; i < 9; ++i) {
    ans += solve(num);
    num += tmp;
  }
  cout << ans << endl;
  return 0;
}
