#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<long long, long long> &a,
               const pair<long long, long long> &b) {
  return (a.second < b.second);
}
inline long long mx(long long a, long long b) {
  if (a > b)
    return a;
  else
    return b;
}
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long solve(long long x, long long n) {
  long long r;
  if (x <= n)
    r = (x - 1) / 2;
  else
    r = (n - (x - n) + 1) / 2;
  if (r > 0)
    return r;
  else
    return 0;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n;
  cin >> n;
  long long i;
  for (i = 9; i <= n + n - 1; i = i * 10 + 9)
    ;
  long long k = i / 10;
  long long ans = 0;
  for (long long i = 0; i <= 9; i++) {
    if (i * (k + 1) + k <= n + n - 1)
      ans += solve(i * (k + 1) + k, n);
    else
      break;
  }
  cout << ans << "\n";
  return 0;
}
