#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  if (n <= 4) {
    cout << n * (n - 1) / 2 << endl;
  } else {
    int ct = 0;
    long long int k = n;
    long long int ans = 0;
    while (k != 0) {
      k = k / 10;
      ct += 1;
    }
    long long int p = 0;
    for (int i = ct - 1; i >= 0; i--) {
      long long int q = 1;
      for (int j = 1; j <= i; j++) {
        q = q * 10;
      }
      p = p + 9 * q;
    }
    if (n + n - 1 >= p) {
      long long int r;
      if (p == n) {
        r = p - n + 1;
      } else
        r = p - n;
      long long int s = p / 2;
      long long int ans = s - r + 1;
      cout << ans << endl;
    } else {
      ans = 0;
      long long int t = 0;
      for (int i = ct - 2; i >= 0; i--) {
        long long int q = 1;
        for (int j = 1; j <= i; j++) {
          q = q * 10;
        }
        t = t + 9 * q;
      }
      long long int w = 1;
      for (int j = 1; j <= ct - 1; j++) {
        w = w * 10;
      }
      for (int i = 0; i <= 8; i++) {
        long long int q = i * w + t;
        if (q > n + n - 1) break;
        if (n >= q) {
          int a = 1;
          int b = q / 2;
          ans += b - a + 1;
        } else {
          long long int a = q - n;
          long long int b = q / 2;
          ans += b - a + 1;
        }
      }
      cout << ans << endl;
    }
  }
}
