#include <bits/stdc++.h>
using namespace std;
int dsum(int x) {
  int ret = 0;
  while (x) ret += (x % 10), x /= 10;
  return ret;
}
int func(int x) {
  while (x > 9) x = dsum(x);
  return x;
}
long long f[10];
long long sum[1000001];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= max(81, n); i++) {
    sum[i] = func(i);
    if (i <= n) f[sum[i]]++;
  }
  long long res = 0;
  for (int i = 0; i < 10; i++)
    for (int j = 0; j < 10; j++)
      for (int k = 0; k < 10; k++)
        if (sum[i * j] == k) res += f[i] * f[j] * f[k];
  for (int i = 1; i <= n; i++)
    for (int j = i; j <= n; j += i)
      if (sum[sum[i] * sum[j / i]] == sum[j]) res--;
  printf("%lld\n", res);
  return 0;
}
