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