#include <bits/stdc++.h>
const long long MOD = 1e9 + 7;
using namespace std;
long long stol(string s) {
  long long number = 0;
  for (int i = 0; i < s.length(); ++i)
    number += (s[i] - '0') * powl(10, s.length() - 1 - i);
  return number;
}
string to_string(long long number) {
  string s = "";
  while (number > 0) {
    string l = "";
    l += (number % 10) + '0';
    s = l + s;
    number /= 10;
  }
  return s;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  long long n;
  cin >> n;
  long long temp = n;
  unsigned long long mul = 0;
  int maxim = 0;
  if (n < 5) return cout << n * (n - 1) / 2, 0;
  while (n > 0) {
    if (n > 9)
      maxim++;
    else
      maxim += (n > 4);
    n /= 10;
  }
  n = temp;
  if (maxim == ((int)log10(n) + 1)) {
    long long start = powl(10, maxim) - 1;
    long long lim = 5 * powl(10, maxim - 1);
    for (long long i = min(start - 1, n); i >= lim; --i) mul++;
  } else {
    int t = 1;
    long long lim = t * (long long)(powl(10, maxim)) - 1;
    while (lim <= 2 * n) {
      long long k = max(lim - n, (long long)1);
      while (k <= lim / 2) {
        k++;
        mul++;
      }
      t++;
      lim = powl(10, maxim) * t - 1;
    }
  }
  cout << mul;
  return 0;
}
