#include <bits/stdc++.h>
using namespace std;
int checkDigits(long long n) {
  if (n % 10 == n)
    return 1;
  else {
    n /= 10;
    return 1 + checkDigits(n);
  }
}
int main() {
  long long n;
  cin >> n;
  long long result = 0;
  long long d = pow(10, checkDigits(n + n - 1 + 2) - 1);
  long long max = (n + n - 1 + 2) / d;
  max *= d;
  max--;
  if (max < 9) {
    cout << (1 + (n - 1)) * (n - 1) / 2;
    return 0;
  }
  while (max != -1) {
    if (n < max - 1) {
      result += n - max / 2;
      max -= d;
    } else {
      result += max / 2;
      max -= d;
    }
  }
  cout << result;
}
