#include <bits/stdc++.h>
using namespace std;
long long n, ans, d[9];
signed main() {
  scanf("%lld", &n);
  for (register int i = 1; i <= n; ++i) ans -= n / i, ++d[i % 9];
  for (register int i = 0; i < 9; ++i)
    for (register int j = 0; j < 9; ++j) ans += d[i] * d[j] * d[i * j % 9];
  return !printf("%lld", ans);
}
