#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios_base::sync_with_stdio(false);
  long long n;
  cin >> n;
  long long nmax = 9999999999;
  while ((nmax / 2) >= n) nmax /= 10;
  int inc = nmax + 1;
  long long ans = 0;
  if (nmax == 0) {
    ans = (n * (n - 1)) / 2;
    cout << ans << endl;
    return 0;
  }
  while (n >= (nmax / 2)) {
    cerr << "ans"
         << " is " << ans << endl;
    ;
    if (n >= nmax)
      ans += (nmax / 2);
    else
      ans += n - (nmax / 2);
    nmax += inc;
  }
  cout << ans << endl;
  return 0;
}
