#include <bits/stdc++.h>
using namespace std;
int f(int x) {
  int r = x;
  do {
    x = r, r = 0;
    while (x) r += x % 10, x /= 10;
  } while (r >= 10);
  return r;
}
int n;
long long c[10];
long long ans;
int main() {
  cin >> n;
  ans = 0;
  memset(c, 0, sizeof(c));
  for (int i = 1; i <= n; i++) {
    c[f(i)]++;
    ans -= n / i;
  }
  for (int i = 1; i <= 9; i++)
    for (int j = 1; j <= 9; j++) {
      int k = f(i * j);
      ans += c[i] * c[j] * c[k];
    }
  cout << ans << endl;
  return 0;
}
