#include <bits/stdc++.h>
using namespace std;
int V[1000010];
long long G[10];
int T[10][10];
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 1, b_ = N; i <= (b_); i++) {
    int r = i % 9;
    if (r == 0) r = 9;
    G[r]++;
  }
  for (int i = 1, b_ = 9; i <= (b_); i++)
    for (int j = 1, b_ = 9; j <= (b_); j++) {
      int r = (i * j) % 9;
      if (r == 0) r = 9;
      T[i][j] = r;
    }
  long long cum = 0;
  for (int i = 1, b_ = N; i <= (b_); i++) {
    for (int k = i; k <= N; k += i) {
      int b = (k / i) % 9;
      int a = i % 9;
      int c = k % 9;
      if (!b) b = 9;
      if (!c) c = 9;
      if (!a) a = 9;
      int d = (a * b) % 9;
      if (!d) d = 9;
      if (d == c) cum++;
    }
  }
  unsigned long long res = 0;
  unsigned long long tot = 0;
  for (int i = 1, b_ = 9; i <= (b_); i++)
    for (int j = 1, b_ = 9; j <= (b_); j++) {
      int y = T[i][j];
      tot += (unsigned long long)G[i] * (unsigned long long)G[j] *
             (unsigned long long)G[y];
    }
  tot -= cum;
  cout << tot << "\n";
  return 0;
}
