#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
const int N = 200005;
long long n;
int main() {
  scanf("%lld", &n);
  if (n < 5) return 0 * printf("%lld", n * (n - 1) / 2);
  int cnt = 0;
  long long sum = 1, ans = 0, sum1 = 0;
  for (long long num = 5; num <= n;
       ++cnt, num *= 10, sum1 += sum * 9, sum *= 10)
    ;
  for (int i = 0; i <= 8; ++i) {
    long long p = 1LL * i * sum + sum1;
    if (p <= n)
      ans += (p - 1) / 2;
    else if ((p + 1) / 2 <= n && n < p)
      ans += n - (p + 1) / 2 + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
