#include <bits/stdc++.h>
using namespace std;
long long solveP(long long n, long long bign) {
  long long a = (n - 1) / 2;
  long long b = (n + 1) / 2;
  long long d2 = (bign - b + 1);
  return min(d2, a);
}
bool allNine(long long n) {
  while (n) {
    if (n % 10 != 9) return false;
    n /= 10;
  }
  return true;
}
long long getBase(long long n) {
  long long current, old;
  current = 9;
  while (current < n) {
    old = current;
    current = (current * 10 + 9);
  }
  return old;
}
long long solve(long long n) {
  if (n < 5) {
    return ((n * (n - 1)) / 2);
  }
  long long maxi = (n + (n - 1));
  long long final = 0;
  long long current;
  if (allNine(maxi))
    return 1;
  else {
    long long d = getBase(maxi);
    current = d;
    while (current <= maxi) {
      final += solveP(current, n);
      current += (d + 1);
    }
    return final;
  }
}
int main() {
  long long n;
  scanf("%lld", &n);
  long long ans = solve(n);
  cout << ans << endl;
  return 0;
}
