#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long ans = 0;
  vector<long long> v(10, 0);
  for (int i = 1; i <= N; ++i) {
    ++v[i % 9 == 0 ? 9 : i % 9];
    ans -= N / i;
  }
  for (int i = 1; i <= 9; ++i)
    for (int j = 1; j <= 9; ++j)
      ans += v[i] * v[j] * v[(i * j) % 9 == 0 ? 9 : (i * j) % 9];
  cout << ans << endl;
  return 0;
}
