#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
long long solve(int n) {
  long long res = 0;
  for (int a = 1; a <= n; ++a)
    for (int b = 1; b <= n; ++b)
      for (int c = 1; c <= n; ++c) {
        if (a * b != c) {
          if (((a % 9) * (b % 9) % 9) == (c % 9)) {
            ++res;
          }
        }
      }
  return res;
}
int f(int n, int a) {
  int res = n / 9;
  if (a == 0) a = 9;
  if (n - 9 * res >= a) ++res;
  return res;
}
int main() {
  int n = 0;
  cin >> n;
  long long res = 0;
  for (int a = 1; a <= 9; ++a)
    for (int b = a; b <= 9; ++b) {
      int Ta = f(n, a);
      int Tb = f(n, b);
      int c = (a * b) % 9;
      int Tc = f(n, c);
      int m = 1;
      if (a != b) ++m;
      long long cur = 0;
      cur = 1LL * (Ta)*Tb * Tc;
      for (int k = 0; k < Ta; ++k) {
        int num = (k != 0 || a != 0)
                      ? (n - 9 * k * b - a * b) / (81 * k + 9 * a)
                      : ((1 << 31) - 1);
        if (n - 9 * k * b - a * b < 0) num = -2;
        num = min(num, Tb - 1);
        if (num < 0) continue;
        cur = cur - (num + 1);
      }
      res += cur * m;
    }
  cout << res;
  return 0;
}
