#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, ans = 0;
  cin >> N;
  long long temp = N;
  long long l = 0;
  while (N > 0) {
    N /= 10;
    l++;
  }
  N = temp;
  long long x = 9;
  for (long long i = 1; i < l; i++) {
    x = x * 10 + 9;
  }
  if (N <= 4) {
    ans = N * (N - 1) / 2;
  } else if (x - N <= N) {
    if (x != N)
      ans = (2 * N - x + 1) / 2;
    else
      ans = N / 2;
  } else {
    x /= 10;
    for (long long i = 0; i <= 9; i++) {
      long long y = i * pow(10, l - 1) + x;
      if (y >= 2 * N + 1) {
        break;
      }
      if (y <= N) {
        ans += (y - 1) / 2;
      } else if (y > N) {
        ans += (2 * N - y + 1) / 2;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
