#include <bits/stdc++.h>
using namespace std;
int n;
int main(void) {
  scanf("%d", &n);
  if (n == 2) {
    printf("1\n");
    return 0;
  }
  if (n == 3) {
    printf("3\n");
    return 0;
  }
  if (n == 4) {
    printf("6\n");
    return 0;
  }
  int maxsum = n - 1 + n;
  int aux = maxsum;
  bool sonove = 1;
  string num;
  while (aux > 0) {
    int d = aux % 10;
    if (d != 9) sonove = 0;
    num += d + '0';
    aux /= 10;
  }
  if (sonove) {
    printf("1\n");
    return 0;
  }
  reverse(num.begin(), num.end());
  sonove = 1, aux = maxsum;
  while (aux > 9) {
    int d = aux % 10;
    if (d != 9) sonove = 0;
    aux /= 10;
  }
  if (!sonove) {
    num[0]--;
    for (int i = 1; i < num.size(); i++) {
      num[i] = '9';
    }
  }
  int largest = stoi(num);
  long long ans = 0;
  while (num[0] >= '0') {
    int cur = stoi(num);
    ans += (cur - 1) / 2;
    if (n < cur) {
      ans -= (cur - n) - 1;
    }
    num[0]--;
  }
  cout << ans << "\n";
  return 0;
}
