#include <bits/stdc++.h>
using namespace std;
void syn() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
}
long long int solve(long long int n, long long int k) {
  long long int ans = 0;
  if (k <= (n + 1))
    ans = (k - 1) / 2;
  else {
    long long int z = k - n;
    ans = (n - z + 1) / 2;
  }
  if (ans < 0) ans = 0;
  return ans;
}
int main() {
  syn();
  long long int n, k, x, ans = 0;
  long long int po[10];
  po[0] = 1;
  cin >> n;
  int m = 0, i;
  for (i = 1; i < 10; i++) po[i] = po[i - 1] * 10;
  int bits = 0;
  x = 2 * n - 1;
  long long int first = 0;
  int cntnine = 0;
  while (x) {
    bits++;
    if (x % 10 == 9) cntnine++;
    first = x % 10;
    x /= 10;
  }
  if (bits == cntnine) {
    cout << "1";
  } else if (n == 2) {
    cout << "1";
  } else if (n == 3) {
    cout << "3";
  } else if (n == 4) {
    cout << "6";
  } else {
    m = bits - 1;
    if (m == cntnine) first++;
    for (i = 0; i < first; i++) {
      k = i * po[m] + po[m] - 1;
      ans += solve(n, k);
    }
    cout << ans;
  }
}
