#include <bits/stdc++.h>
using namespace std;
const long long infl = 1e18 + 5;
long long int n, m, k, q, x, y, f, val, t = 1, i, j;
long long int ind = -1, cnt, sz, sm, ans, mx = -1, mn = infl;
long long int a[1000004];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  if (fopen("inp.txt", "r")) {
    freopen("myfile.txt", "w", stdout);
    freopen("inp.txt", "r", stdin);
  }
  cin >> n;
  long long int px = 0;
  x = 9;
  while (true) {
    if (n + n - 1 < x) break;
    px = x;
    cnt++;
    x = x * 10 + 9;
  }
  if (px == 0) {
    cout << (n * (n - 1)) / 2;
  } else {
    val = px + 1;
    while (true) {
      long long int s = (px + 1) / 2;
      if (s >= px || s > n) break;
      ans += min(px - 1, n) - s + 1;
      px += val;
    }
    cout << ans;
  }
  return 0;
}
