#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const double PI = 2 * acos(0.0);
const double EPS = 1e-8;
const int INF = 1000000000;
int tc, n, cnt, j;
long long ans;
long long c1[10], c2[10];
int p, c[100];
int sr(int n) {
  if (n < 10) return n;
  int res = 0;
  while (n) {
    res += n % 10;
    n /= 10;
  };
  return sr(res);
};
int main() {
  cin >> n;
  if (n == 1) {
    cout << 0;
    return 0;
  };
  for (int i = (int)(0); i < (int)(n); ++i) ++c1[sr(i + 1)];
  for (int i = (int)(0); i < (int)(10); ++i)
    for (int j = (int)(0); j < (int)(10); ++j) c2[sr(i * j)] += c1[i] * c1[j];
  for (int i = (int)(0); i < (int)(10); ++i) ans += c1[i] * c2[i];
  for (int i = 1; i <= n; ++i) {
    p = 0;
    cnt = i;
    for (j = 2; j * j <= cnt; ++j)
      if (cnt % j == 0) {
        c[p] = 0;
        while (cnt % j == 0) {
          ++c[p];
          cnt /= j;
        };
        ++p;
      };
    if (cnt > 1) c[p++] = 1;
    cnt = 1;
    for (int j = (int)(0); j < (int)(p); ++j) cnt *= c[j] + 1;
    ans -= cnt;
  };
  cout << ans;
  return 0;
};
