#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  long long a = 500000000, b = 499999999, c = 999999999, d = 1000000000;
  cin >> n;
  if (n < 5) {
    if (n == 1)
      cout << 0 << endl;
    else if (n == 2)
      cout << 1 << endl;
    else if (n == 3)
      cout << 3 << endl;
    else if (n == 4)
      cout << 6 << endl;
    return 0;
  }
  long long ans;
  while (a >= 5) {
    if (n >= a) {
      if (n >= c) {
        long long x = n / d;
        long long y = n % d;
        ans = x * x * a + y * x + max(0ll, y - a + 1);
        if (x == 1 && n < a + d) ans = n - d + b + 1;
        if (n % d == d - 1) ans = ans - 1;
      } else
        ans = a - (c - n);
      cout << ans << endl;
      break;
    }
    a /= 10;
    b /= 10;
    c /= 10;
    d /= 10;
  }
  return 0;
}
