#include <bits/stdc++.h>
const long long N = 1e6 + 6;
long long sum[10], drt[N];
int main() {
  long long n;
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) sum[i % 9]++;
  long long ans = 0;
  for (long long i = 0; i < 9; i++)
    for (long long j = 0; j < 9; j++) ans += sum[i] * sum[j] * sum[i * j % 9];
  for (long long i = 1; i <= n; i++) ans -= n / i;
  printf("%lld\n", ans);
  return 0;
}
