#include <bits/stdc++.h>
using namespace std;
long long n;
long long mmax, k, ans;
signed main() {
  cin >> n;
  mmax = (n + (n - 1));
  while (k * 10 + 9 <= mmax) k = k * 10 + 9;
  if (!k) {
    cout << n * (n - 1) / 2 << "\n";
    return 0;
  }
  for (long long i = 0; i < 9; i++) {
    if (i * (k + 1) + k > mmax) break;
    if (i * (k + 1) + k <= n + 1)
      ans += (i * (k + 1) + k) / 2;
    else
      ans += (i * (k + 1) + k) / 2 - ((i * (k + 1) + k - 1) - n);
  }
  cout << ans << "\n";
}
