#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
template <typename T>
T pow(T a, T b, long long m) {
  T ans = 1;
  while (b > 0) {
    if (b % 2 == 1) ans = (ans * a) % m;
    b /= 2;
    a = (a * a) % m;
  }
  return ans % m;
}
const long long N = 100000 + 5;
long long naruto(long long x) {
  long long res = 0;
  while (x != 0) {
    x /= 10;
    res++;
  }
  return res;
}
bool kaguya(long long x) {
  while (x != 0) {
    long long p = x % 10;
    if (p != 9) return false;
    x /= 10;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  long long x = n + (n - 1);
  if (n < 5)
    cout << n * (n - 1) / 2 << endl;
  else if (kaguya(x)) {
    cout << "1" << endl;
  } else {
    long long p = naruto(x) - 1;
    long long z = pow(10, p) - 1;
    long long ans = 0;
    while (z <= x) {
      if (z <= n) {
        ans += z / 2;
      } else
        ans += (n - z / 2);
      z += pow(10, p);
    }
    cout << ans << endl;
  }
}
