#include <bits/stdc++.h>
using namespace std;
long long temp2;
long long fn(long long n) {
  long long ans(0);
  while (ans <= n) {
    ans *= 10;
    ans += 9;
  }
  ans -= 9;
  ans /= 10;
  temp2 = ans + 1;
  return ans;
}
long long cal(long long temp, long long n) {
  long long i = temp - n;
  i = max(i, (long long)1);
  if (i > n) return 0;
  temp--;
  return temp / 2 - i + 1;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, temp, ans(0);
  cin >> n;
  temp = 2 * n - 1;
  temp = fn(temp);
  for (int i = 0; i <= 8; i++) {
    ans += cal(i * temp2 + temp, n);
  }
  cout << ans;
  return 0;
}
