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