#include <bits/stdc++.h>
using namespace std;
inline int d(int i) { return ((i - 1) % 9) + 1; }
int a[1000000 + 1];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) a[d(i)] += 1;
  long long ans = 0;
  for (int i = 1; i < 10; i++)
    for (int j = 1; j < 10; j++)
      for (int k = 1; k < 10; k++)
        if (d(i * j) == k) ans += (long long)a[i] * a[j] * a[k];
  for (int i = 1; i <= n; i++) ans -= (n / i);
  cout << ans << endl;
  return 0;
}
