#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long m = n + n - 1;
  long long k = 0, p = 0;
  while (1) {
    if (k * 10 + 9 > m) break;
    k = k * 10 + 9;
  }
  if (k == 0) {
    cout << n * (n - 1) / 2;
    return 0;
  }
  long long kk = k + 1;
  long long res = 0;
  while (k <= m) {
    long long u = k / 2 + 1;
    long long d = k / 2;
    res += min(d, n - u + 1);
    k += kk;
  }
  cout << res;
}
