#include <bits/stdc++.h>
using namespace std;
class Solution {
  long long grid[10] = {};
  int n;

 public:
  void run(istream &in, ostream &out) {
    cin >> n;
    long long ans = 0;
    for (int i = 1; i <= n; ++i)
      for (int j = i; j <= n; j += i) --ans;
    for (int i = 1; i <= n; ++i) {
      ++grid[i % 9 == 0 ? 9 : i % 9];
    }
    for (int i = 1; i <= 9; ++i) {
      for (int j = 1; j <= 9; ++j) {
        ans += grid[i] * grid[j] * grid[i * j % 9 == 0 ? 9 : i * j % 9];
      }
    }
    cout << ans << '\n';
  }
};
int main() {
  std::ios_base::sync_with_stdio(false);
  Solution().run(std::cin, std::cout);
  return 0;
}
