#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T min(T a, T b, T c) {
  return min(min(a, b), c);
}
template <class T>
inline T max(T a, T b, T c) {
  return max(max(a, b), c);
}
template <class T>
inline void checkmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void checkmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline T sq(T x) {
  return x * x;
}
template <class T>
inline int countbit(T n) {
  return (n == 0) ? 0 : 1 + countbit(n & (n - 1));
}
template <class T>
inline T gcd(T a, T b) {
  return b == 0 ? a : gcd(b, a % b);
}
template <class T>
inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
const int N = 50005;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
long long a[9];
int main() {
  int n;
  cin >> n;
  long long ans = 0;
  for (int i = (1); i <= (n); ++i) ++a[i % 9], ans -= n / i;
  for (int i = (0); i < (10); ++i)
    for (int j = (0); j < (10); ++j) ans += a[i] * a[j] * a[(i * j) % 9];
  cout << ans << endl;
  return 0;
}
