#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const long long mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double eps = 1e-6;
long long ans[maxn];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long sum = 0;
  for (int i = 1; i <= n; ++i) ans[1 + (i - 1) % 9]++, sum -= n / i;
  for (int i = 1; i <= 9; ++i) {
    for (int j = 1; j <= 9; ++j) {
      sum += ans[i] * ans[j] * ans[1 + (i * j - 1) % 9];
    }
  }
  cout << sum << endl;
  return 0;
}
