#include <bits/stdc++.h>
using namespace std;
long long a[2000010], d[2000010];
long long b[200010], f[1010][1010];
long long mn = 1e18, mx = -1e18, ans, sm = 1, cnt, n, m, cur;
bool ok, u[1000010], uu[310][310];
char c[510][510], cc[100010];
int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
vector<long long> g[900010];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  long long x = 2 * n - 1;
  m = x;
  if (n < 5) {
    cout << (n * (n - 1)) / 2;
    return 0;
  }
  if (n == 5) {
    cout << 1;
    return 0;
  }
  while (m) {
    cnt++;
    if (m % 10 == 9) {
      cur++;
    }
    m /= 10;
  }
  sm = 0;
  long long but = x / (pow(10, cnt - 1));
  if (cnt == 1 && x >= 9) {
    sm = 9;
    but = 0;
  }
  if (cur == cnt) {
    cnt++;
  }
  for (int i = 0; i < cnt - 1; i++) {
    sm *= 10;
    sm += 9;
  }
  long long k;
  for (int i = 0; i <= but; i++) {
    if ((sm + 1) * i + sm <= x) {
      k = (sm + 1) * i + sm;
      if (n < k) {
        ans += (n + 1 - (k - n)) / 2;
      } else {
        ans += min(n, k) / 2;
      }
    }
  }
  cout << ans;
  return 0;
}
