#include <bits/stdc++.h>
using namespace std;
long long cal(long long n, long long x) {
  if (x <= n) {
    return (x - 1) / 2;
  } else if (x <= n + n - 1) {
    return (n + n + 1 - x) / 2;
  } else {
    return 0;
  }
}
int main() {
  long long n;
  cin >> n;
  long long sum = (n << 1) - 1;
  bool allNine = true;
  long long x = sum;
  while (x) {
    if (x % 10 != 9) {
      allNine = false;
      break;
    }
    x /= 10;
  }
  if (allNine) {
    cout << 1 << endl;
    return 0;
  }
  long long a = 9;
  long long b = 10;
  while (a < sum) {
    a *= 10;
    a += 9;
    b *= 10;
  }
  a /= 10;
  b /= 10;
  long long ans = 0;
  while (a <= sum) {
    ans += cal(n, a);
    a += b;
  }
  cout << ans << endl;
  return 0;
}
