#include <bits/stdc++.h>
int dx[] = {-1, -1, -1, 0, 1, 1, 1, 0};
int dy[] = {-1, 0, 1, 1, 1, 0, -1, -1};
using namespace std;
long long power(long long a, long long p, long long M) {
  long long r = 1;
  a = a % M;
  while (p > 0) {
    if (p % 2) r = (r * a) % M;
    a = (a * a) % M;
    p /= 2;
  }
  return r;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long x = (long long)5e10;
long long y = 9999999999;
void solve() {
  long long n;
  cin >> n;
  if (n < 5) {
    cout << n * (n - 1) / 2 << endl;
    return;
  }
  while (n / x == 0) x /= 10;
  y = x;
  long long ans = 0;
  ans += max(0LL, min(y - 1, 1 + n - y));
  ans += max(0LL, min(2 * y - 1, 1 + n - 2 * y));
  ans += max(0LL, min(3 * y - 1, 1 + n - 3 * y));
  ans += max(0LL, min(4 * y - 1, 1 + n - 4 * y));
  ans += max(0LL, min(5 * y - 1, 1 + n - 5 * y));
  ans += max(0LL, min(6 * y - 1, 1 + n - 6 * y));
  ans += max(0LL, min(7 * y - 1, 1 + n - 7 * y));
  ans += max(0LL, min(8 * y - 1, 1 + n - 8 * y));
  ans += max(0LL, min(9 * y - 1, 1 + n - 9 * y));
  cout << ans << endl;
}
int main() {
  solve();
  return 0;
}
