#include <bits/stdc++.h>
int main() {
  int n;
  long long int ans = 0, c[1010000], a[10];
  scanf("%d", &n);
  for (int i = 0; i < 10; i++) a[i] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j * i <= n; j++) c[i * j]++;
    a[i % 9]++;
  }
  for (int i = 0; i < 9; i++)
    for (int j = 0; j < 9; j++) ans += a[i] * a[j] * a[(i * j) % 9];
  for (int i = 1; i <= n; i++) ans -= c[i];
  printf("%lld\n", ans);
}
