#include <bits/stdc++.h>
using namespace std;
long long ways(long long n, long long num) {
  if (n > num) {
    return ((num - 1) / 2);
  }
  long long k = num - n;
  if (k == 0) {
    return (n / 2);
  }
  if (n > k) {
    return ((n - k + 1) / 2);
  }
  return (0);
}
int main() {
  long long n;
  cin >> n;
  if (n == 2) {
    cout << 1;
    return 0;
  }
  if (n == 3) {
    cout << 3;
    return 0;
  }
  if (n == 4) {
    cout << 6;
    return 0;
  }
  long long k = 2 * n;
  long long maxnines = 0;
  while (k >= 10) {
    maxnines++;
    k = k / 10;
  }
  long long big = 1;
  for (long long i = 0; i < maxnines; i++) {
    big *= 10;
  }
  long long way = 0;
  for (long long t = 1; t <= 10; t++) {
    long long goal = t * big;
    goal--;
    way += ways(n, goal);
  }
  cout << way;
  return 0;
}
