#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100;
const int INF = 0x3f3f3f3f;
int main() {
  int len = 0;
  long long n, x, sum, t = 1ll;
  cin >> n;
  sum = n + n - 1;
  x = sum;
  while (x) {
    len++;
    x /= 10;
    t *= 10;
  }
  if (sum == t - 1)
    cout << "1\n";
  else if (n <= 10) {
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = i + 1; j <= n; j++) {
        if ((i + j) % 10 == 9) ans++;
      }
    }
    if (ans != 0)
      cout << ans << endl;
    else
      cout << n * (n - 1) / 2 << endl;
  } else {
    long long ans = 0;
    t /= 10;
    long long temp = t - 1;
    for (int i = 0; i <= 8; i++) {
      long long nt = t * i;
      long long p = nt + temp;
      if (p <= n + 1)
        ans += (p - 1) / 2;
      else if (p > n + n - 1)
        ;
      else
        ans += (2 * n - p + 1) / 2;
    }
    cout << ans << endl;
  }
  return 0;
}
