#include <bits/stdc++.h>
using namespace std;
void add_edge(vector<long long> adj[], long long a, long long b) {
  adj[a].push_back(b);
  adj[b].push_back(a);
}
class myComparator {
 public:
  int operator()(int p1, int p2) { return p1 > p2; }
};
long long fun(long long x, long long n) {
  long long mid, beg = 1, last = x / 2;
  while (beg < last) {
    mid = (beg + last) / 2;
    long long t = x - mid;
    if (t <= n) {
      last = mid;
    } else {
      beg = mid + 1;
    }
  }
  return (x / 2) - last + 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long n;
  cin >> n;
  long long t = (2 * n) - 1;
  string v = to_string(t);
  string s;
  long long i;
  for (i = 0; i < v.size(); i++) s += '9';
  long long num = stoll(s);
  if (num > t) {
    num /= 10;
    s.pop_back();
  }
  long long ans = 0;
  for (i = 0; i < 9; i++) {
    string temp = to_string(i);
    string ma = temp + s;
    long long num = stoll(ma);
    if (num > t) break;
    ans += fun(num, n);
  }
  if (n > 4)
    cout << ans << endl;
  else {
    long long k;
    long long ans = 1;
    for (k = 3; k <= n; k++) ans *= k;
    if (n == 4) ans = ans / 2;
    cout << ans << endl;
  }
  return 0;
}
