#include <bits/stdc++.h>
using namespace std;
long long GetOfMod(long long n, long long k) {
  n--;
  k = (k + 8) % 9;
  return n / 9 + (n % 9 >= k);
}
long long solve(long long n) {
  long long good = 0;
  long long fake = 0;
  for (long long c = 0; c < 9; c++) {
    for (long long a = 0; a < 9; a++) {
      for (long long b = 0; b < 9; b++) {
        if ((a * b) % 9 == c) {
          fake += GetOfMod(n, c) * GetOfMod(n, a) * GetOfMod(n, b);
        }
      }
    }
  }
  int STEPS = 0;
  for (long long a = 1; a <= n; a++) {
    good += n / a;
    STEPS++;
  }
  return fake - good;
}
inline void init() {}
int main() {
  init();
  long long n;
  while (cin >> n) {
    cout << solve(n) << endl;
  }
  return 0;
}
