#include <bits/stdc++.h>
using namespace std;
long long int n;
int main() {
  cin >> n;
  if (n < 5) {
    cout << n * (n - 1) / 2 << endl;
    return 0;
  }
  long long int s = n * 2 - 1;
  long long int ss = s;
  long long int l = 0;
  bool nines = true;
  while (ss) {
    if (ss % 10 != 9) nines = false;
    ss /= 10;
    l++;
  }
  if (nines) {
    cout << 1 << endl;
    return 0;
  }
  long long int sum = 0;
  l--;
  while (l--) {
    sum *= 10;
    sum += 9;
  }
  long long int r = sum + 1;
  long long int ans = 0;
  while (sum <= s) {
    long long int down, up;
    down = (sum + 1) / 2;
    if (down > n) break;
    up = min(sum - 1, n);
    ans += up - down + 1;
    sum += r;
  }
  cout << ans << endl;
  return 0;
}
