#include <bits/stdc++.h>
using namespace std;
long long n;
long long cnt[1000010];
inline long long d(long long x) { return x % 9 == 0 ? 9 : x % 9; }
signed main() {
  scanf("%lld", &n);
  for (register long long i = 1; i <= n; i++) {
    cnt[d(i)]++;
  }
  long long ans1 = 0;
  long long ans2 = 0;
  for (register long long i = 1; i <= 9; i++) {
    for (register long long j = 1; j <= 9; j++) {
      for (register long long k = 1; k <= 9; k++) {
        if (i * j % 9 == k % 9) ans1 += cnt[i] * cnt[j] * cnt[k];
      }
    }
  }
  long long ok = 0;
  for (register long long i = 1; i <= n; i++) {
    ans2 += n / i;
  }
  printf("%lld", ans1 - ans2);
  return 0;
}
