#include <bits/stdc++.h>
using namespace std;
const int maxn = 12;
unsigned long long ans;
unsigned long long n;
unsigned long long data[maxn];
void init() {
  scanf("%I64d", &n);
  memset(data, 0, sizeof(data));
  ans = 0;
}
void solve() {
  for (int i = 1; i <= n; ++i) {
    ++data[i % 9];
    ans -= n / i;
  }
  for (int i = 0; i < 9; ++i)
    for (int j = 0; j < 9; ++j) ans += data[i] * data[j] * data[i * j % 9];
}
void write() { printf("%I64d\n", ans); }
int main() {
  init();
  solve();
  write();
  return 0;
}
