#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int INF = 1e9;
const long long LINF = 1LL * INF * INF;
const int MAXN = 5007;
const double EPS = 1e-7;
long long n, P[10];
int main() {
  ios_base::sync_with_stdio(0);
  P[0] = 1;
  for (int i = (1); i < (10); ++i) P[i] = P[i - 1] * 10;
  cin >> n;
  if (n < 5) {
    cout << n * (n - 1) / 2;
    return 0;
  }
  for (int k = (10) - 1; k >= (0); --k) {
    long long cnt = 0, cur = P[k] - 1;
    for (int d = (0); d < (9); ++d) {
      cnt += max(0LL, min(n, cur - 1) - (cur + 2) / 2 + 1);
      cur += P[k];
    }
    if (cnt) {
      cout << cnt;
      break;
    }
  }
  return 0;
}
