#include <bits/stdc++.h>
using namespace std;
int D(int first) { return first % 9 == 0 ? 9 : first % 9; }
long long go(int n) {
  long long d[10], dp[10];
  memset(d, 0, sizeof(d));
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i <= n; i++) d[D(i)]++;
  for (int i = 1; i <= 9; i++)
    for (int j = 1; j <= n; j++) dp[i] += d[D(i * D(j))];
  long long ret = 0;
  for (int i = 1; i <= n; i++) ret += dp[D(i)] - n / i;
  return ret;
}
void solution() {
  int n;
  cin >> n;
  long long ans = go(n);
  cout << ans << endl;
}
int main() {
  solution();
  return 0;
}
