#include <bits/stdc++.h>
using namespace std;
int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};
template <typename T>
inline T BigMod(T A, T B) {
  T ret = 1;
  while (B) {
    if (B & 1) ret = (ret * A) % 1000000007;
    A = (A * A) % 1000000007;
    B = B >> 1;
  }
  return ret;
}
template <typename T>
inline T InvMod(T A, T M = 1000000007) {
  return BigMod(A, M - 2);
}
string tostring(long long int res) {
  string curstr = "";
  while (res != 0) {
    long long int temp = (res % 10);
    curstr += ((char)temp + '0');
    res /= 10;
  }
  reverse(curstr.begin(), curstr.end());
  return curstr;
}
long long int toint(string ss) {
  long long int inss = 0;
  for (int i = 0; i < ss.size(); i++) {
    inss = (inss * 10) + ((int)(ss[i] - '0'));
  }
  return inss;
}
bool check(string s) {
  for (int i = 0; i < s.length(); i++)
    if (s[i] != '9') return 0;
  return 1;
}
int main() {
  long long int n;
  cin >> n;
  long long int temp = (n - 1) + n;
  string str = tostring(temp);
  if (check(str)) {
    cout << 1 << endl;
    return 0;
  }
  int len = str.length() - 1;
  string cur = "0";
  while (len--) cur += '9';
  long long int ans = 0;
  for (int i = 0; i <= 8; i++) {
    cur[0] = (char)i + '0';
    long long int curtemp = toint(cur);
    long long int koyta;
    koyta = (curtemp % 2) ? curtemp / 2 : (curtemp / 2) - 1;
    if (curtemp > temp)
      ans += 0;
    else if (curtemp > n) {
      long long int joghobe = koyta;
      joghobe -= ((curtemp - n) - 1);
      if (joghobe > 0) ans += joghobe;
    } else if (curtemp <= n) {
      if (koyta > 0) ans += koyta;
    }
  }
  cout << ans << endl;
  return 0;
}
