#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
void __never(int a) { printf("\nOPS %d", a); }
long long os[10];
long long os2[10];
int n;
int f[3000000];
int F(int a) {
  if (a == 1) return 1;
  int res = 0;
  for (int i = 2; i * i <= a; i++)
    if (a % i == 0) {
      if (i * i == a)
        res++;
      else {
        res += 2;
      }
    }
  return res + 2;
}
int F2(int a) {
  if (a == 1) return 1;
  int res = 1;
  for (int i = 2; i * i <= a; i++)
    if (a % i == 0) {
      int h = 0;
      while (a % i == 0) {
        h++;
        a /= i;
      }
      res *= (h + 1);
    }
  if (a > 1) res *= 2;
  return res;
}
void init() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
void sol() {
  scanf("%d", &n);
  for (int(i) = (1); (i) <= (n); ++(i)) os[i % 9]++;
  for (int(i) = (0); (i) <= (8); ++(i)) {
    os2[i] = 0;
    for (int(I) = (0); (I) <= (8); ++(I))
      for (int(J) = (0); (J) <= (8); ++(J)) {
        int h = (I * J) % 9;
        if (h == i) {
          os2[i] += os[I] * os[J];
        }
      }
  }
  long long ans = 0;
  for (int(i) = (1); (i) <= (n); ++(i)) {
    ans += (os2[i % 9] - F2(i));
  }
  cout << ans;
}
int main() {
  sol();
  return 0;
}
