#include <bits/stdc++.h>
using namespace std;
long long modulo(long long base, long long exponent, long long modulus);
long long choose(long long n, long long k);
long long inverse(long long a, long long m);
void build() {}
int main() {
  build();
  long long n;
  cin >> n;
  if (n < 5) {
    cout << (n * (n - 1)) / 2 << endl;
    return 0;
  }
  long long five = 5;
  long long nine = 9;
  long long realfive;
  long long realnine;
  while (five <= n) {
    realfive = five;
    realnine = nine;
    five = 10 * five;
    nine = 10 * nine + 9;
  }
  nine = realnine;
  five = realfive;
  long long ans = 0;
  while (five <= n) {
    ans += min(nine - 1, n) - (five - 1);
    nine = nine + (realnine + 1);
    five = ceil(nine / 2.0);
  }
  cout << ans << endl;
  return 0;
}
long long modulo(long long base, long long exponent, long long modulus) {
  if (modulus == 1) return 0;
  long long result = 1;
  base = base % modulus;
  while (exponent > 0) {
    if (exponent % 2 == 1) {
      result = (result * base) % modulus;
    }
    exponent = exponent >> 1;
    base = (base * base) % modulus;
  }
  return result;
}
long long choose(long long n, long long k) {
  if (k == 0) return 1;
  return (n * choose(n - 1, k - 1)) / k;
}
void EE(long long a, long long b, long long &co1, long long &co2) {
  if (a % b == 0) {
    co1 = 0;
    co2 = 1;
    return;
  }
  EE(b, a % b, co1, co2);
  long long temp = co1;
  co1 = co2;
  co2 = temp - co2 * (a / b);
}
long long inverse(long long a, long long m) {
  long long x, y;
  EE(a, m, x, y);
  if (x < 0) x += m;
  return x;
}
