#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int N = int(1e6);
int cd[N + 31];
int dr[N + 31];
int cdr[N + 31];
int sd(int x) {
  int res = 0;
  while (x) {
    res += x % 10;
    x /= 10;
  }
  return res;
}
void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  for (int i = (1); i < int(n + 1); ++i) {
    for (int j = i; j <= n; j += i) {
      cd[j]++;
    }
  }
  for (int i = (1); i < int(N + 1); ++i) {
    int s = sd(i);
    if (s <= 9) {
      dr[i] = s;
    } else {
      dr[i] = dr[s];
    }
    if (i <= n) {
      cdr[dr[i]]++;
    }
  }
  lint ans = 0;
  for (int i = (1); i < int(n + 1); ++i) {
    ans -= cd[i];
    for (int a = (1); a < int(10); ++a) {
      for (int b = (1); b < int(10); ++b) {
        if (dr[a * b] == dr[i]) {
          ans += 1LL * cdr[a] * cdr[b];
        }
      }
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve(cin, cout);
  return 0;
}
