#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1000005;
long long D[maxn];
long long S[105];
inline long long s(long long x) {
  long long ans = 0;
  while (x) {
    ans += x % 10;
    x /= 10;
  }
  return ans;
}
inline long long d(long long x) {
  if (~D[x]) return D[x];
  if (x <= 9)
    return D[x] = x;
  else
    return D[x] = d(s(x));
}
signed main() {
  memset(D, 0xff, sizeof(D));
  long long n;
  scanf("%lld", &n);
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) S[d(i)]++;
  for (long long i = 0; i <= 9; ++i)
    for (long long j = 0; j <= 9; ++j) ans += S[i] * S[j] * S[d(i * j)];
  for (long long i = 1; i <= n; ++i) ans -= n / i;
  printf("%lld", ans);
  return 0;
}
