#include <bits/stdc++.h>
using namespace std;
long long ans;
inline long long d(long long a) { return (a % 9) ? (a % 9) : 9; }
long long cnt[10], n, ansx;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cnt[d(i)]++;
  }
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      for (int k = 1; k <= 9; k++) {
        if (i * j % 9 == k % 9) {
          ans += cnt[i] * cnt[j] * cnt[k];
        }
      }
    }
  }
  for (long long l = 1, r; l <= n; l = r + 1) {
    r = min(n, n / (n / l));
    ans -= (n / l) * (r - l + 1);
  }
  cout << ans;
}
