#include <bits/stdc++.h>
using namespace std;
long long d(long long n) {
  n %= 9;
  if (n == 0) n = 9;
  return n;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long T = 1;
  while (T--) {
    long long n;
    cin >> n;
    long long res = 0, dp[10] = {};
    for (long long i = 1; i <= n; i++) {
      dp[d(i)]++;
      res -= n / i;
    }
    for (long long i = 1; i <= 9; i++) {
      for (long long j = 1; j <= 9; j++) res += dp[i] * dp[j] * dp[d(i * j)];
    }
    cout << res << '\n';
  }
  return 0;
}
