#include <bits/stdc++.h>
using namespace std;
long long a[9];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, ans1 = 0, ans2 = 0;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    ans1 += n / i;
    a[i % 9]++;
  }
  for (long long i = 0; i < 9; i++)
    for (long long j = 0; j < 9; j++) ans2 += a[i] * a[j] * a[(i * j) % 9];
  cout << ans2 - ans1;
}
