#include <bits/stdc++.h>
using namespace std;
long long d[10];
int main() {
  int n;
  long long cnt1 = 0, cnt2 = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) d[i % 9]++;
  for (int i = 1; i <= n; i++) cnt1 += n / i;
  for (int i = 0; i < 9; i++)
    for (int j = 0; j < 9; j++) cnt2 += d[i] * d[j] * d[(i * j) % 9];
  cout << cnt2 - cnt1 << endl;
}
