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