#include <bits/stdc++.h>
using namespace std;
const int len = 1e3 + 10;
const double pi = acos(-1.0);
const long long mod = 998244353;
const int inf = 0x3f3f3f3f;
int main() {
  long long n;
  cin >> n;
  if (n <= 4) {
    int gg = 0;
    if (n == 2)
      gg = 1;
    else if (n == 3)
      gg = 3;
    else if (n == 4)
      gg = 6;
    cout << gg << endl;
    return 0;
  }
  long long sum = n + n - 1;
  long long p = 1;
  for (int i = 1; i <= (int)log10(sum); ++i) p *= 10;
  long long y = 1;
  for (int i = 1; i <= (int)log10(n); ++i) y *= 10;
  if (y * 10 == sum + 1)
    cout << 1 << endl;
  else {
    long long ans = 0;
    for (int i = 1; i <= 10; ++i) {
      long long x = p / 2 * i;
      if (x + x - 1 > sum) break;
      ans += min(x + x - 2, n) - x + 1;
    }
    cout << ans << endl;
  }
}
