#include <bits/stdc++.h>
using namespace std;
const int N = 150000;
string s;
int mx, mxDig;
long long dp[11][2][2][2][2];
long long solve(int i, bool less1, bool less2, bool zero1, bool zero2) {
  if (i == -1) return (!zero1 && !zero2) ? 1 : 0;
  long long& ret = dp[i][less1][less2][zero1][zero2];
  if (~ret) return ret;
  ret = 0;
  if (i > mx) {
    for (int j = 0; j <= (s[i] - '0'); j++) {
      for (int k = 0; k <= (s[i] - '0'); k++) {
        if (j + k > mxDig) continue;
        ret += solve(i - 1, j < (s[i] - '0'), k < (s[i] - '0'), zero1 && j == 0,
                     zero2 && k == 0);
      }
    }
  } else {
    for (int j = 0; j <= (less1 ? 9 : s[i] - '0'); j++) {
      for (int k = 9 - j; k <= (less2 ? 9 : s[i] - '0') && k + j <= 9; k++) {
        if (j + k != 9) continue;
        ret += solve(i - 1, less1 || (j < (s[i] - '0')),
                     less2 || (k < (s[i] - '0')), zero1 && j == 0,
                     zero2 && k == 0);
      }
    }
  }
  return ret;
}
int main() {
  int n;
  cin >> n;
  if (n <= 4) return cout << n * (n - 1) / 2, 0;
  stringstream ss;
  int temp = n + (n - 1);
  while (temp >= 10) temp /= 10;
  mxDig = temp;
  temp = 2 * n - 1;
  long long curr = 0;
  while (true) {
    curr *= 10;
    curr += 9;
    if (curr > temp) break;
    mx++;
  }
  mx--;
  ss << n;
  ss >> s;
  reverse(s.begin(), s.end());
  memset(dp, -1, sizeof dp);
  printf("%I64d", solve(s.length() - 1, 0, 0, 1, 1) / 2);
  return 0;
}
