#include <bits/stdc++.h>
using namespace std;
constexpr double pi = 3.141592653589793238462643383279502884L;
const int sz = 1e5;
int main() {
  ios::sync_with_stdio(false);
  long long int n;
  cin >> n;
  long long int t = n + n - 1;
  string num(12, '9');
  int p = -1;
  for (int i = 0; i < num.size(); ++i) {
    num[i] = '0';
    long long int v = atoll(num.c_str());
    if (v <= t) {
      p = i;
      break;
    }
  }
  int ans = 0;
  set<pair<int, int> > rec;
  do {
    for (int j = 0; j < 10; ++j) {
      num[p] = '0' + j;
      long long int v = atoll(num.c_str());
      long long int i = max<long long int>(1, v - n);
      if (i < (v + 1) / 2) {
        ans += min((v + 1) / 2, n) - i;
      }
    }
    break;
  } while (true);
  cout << ans << endl;
}
