#include <bits/stdc++.h>
using namespace std;
inline long long len(long long x) {
  x++;
  long long ret = 0;
  while (x) {
    x /= 10;
    ret++;
  }
  long long cnt = 1;
  for (long long i = 1; i < ret; ++i) cnt *= 10;
  return cnt;
}
int main() {
  ios_base::sync_with_stdio(false);
  long long n;
  cin >> n;
  if (2 * n < 10) {
    cout << n * (n - 1) / 2 << endl;
    return 0;
  }
  long long ans = 0;
  long long x = 2 * n - 1;
  long long y = len(x) - 1;
  for (long long i = 0; i < 9; ++i) {
    long long u = (i + 1) * len(x) - 1;
    long long minn = (u + 1) / 2;
    long long maxx = min(u - 1, n);
    long long a = maxx - minn + 1;
    if (a < 0) a = 0;
    ans += a;
  }
  cout << ans << endl;
  return 0;
}
