#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int dr(int x) {
  int ans = 0;
  while (x) {
    ans += x % 10;
    x /= 10;
  }
  if (ans < 10) return ans;
  return dr(ans);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> cts(10), pcs(10), drval(n + 1);
  for (int i = 1; i <= n; i++) {
    drval[i] = dr(i);
    cts[drval[i]]++;
  }
  long long ans = 0;
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      pcs[dr(i * j)] += cts[i] * cts[j];
    }
  }
  vector<int> pr(1000000);
  for (int i = 2; i < 1000000; i++) {
    if (pr[i]) continue;
    for (int j = i; j <= 1000000; j += i) pr[j] = i;
  }
  for (int i = 1; i <= n; i++) {
    long long pct = 1;
    int x = i;
    while (x > 1) {
      int ct = 0;
      int p = pr[x];
      while (!(x % p)) {
        ct++;
        x /= p;
      }
      pct *= (ct + 1);
    }
    ans += pcs[drval[i]] - pct;
  }
  cout << ans;
  return 0;
}
