#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9 + 7;
const int maxn = (int)2e5 + 7;
const long long BW = (long long)1e16;
const double eps = 1e-6;
bool eq(const double &a, const double &b) { return fabs(a - b) < eps; }
bool ls(const double &a, const double &b) { return a + eps < b; }
bool le(const double &a, const double &b) { return eq(a, b) || ls(a, b); }
int nine[] = {0, 9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999};
int c[] = {0, 0, 1, 3, 6};
int n;
void Init() {}
int Solve() {
  if (n <= 4) return !printf("%d\n", c[n]);
  int num = upper_bound(nine, nine + 10, n << 1) - nine - 1;
  int ans = 0;
  for (int i = (0); i < (9); ++i) {
    long long tmp = 1ll * i * (nine[num] + 1) + nine[num];
    long long t = (tmp + 1) >> 1;
    if (n >= tmp) {
      ans += (tmp >> 1);
    } else if (n >= t) {
      ans += n - t + 1;
    } else {
      break;
    }
  }
  return !printf("%d\n", ans);
}
int main() {
  while (~scanf("%d", &n)) {
    Init();
    Solve();
  }
  return 0;
}
