#include <bits/stdc++.h>
using namespace std;
int f(int a) {
  if (a < 10) return a;
  int k = 0;
  while (a > 0) {
    k += a % 10;
    a /= 10;
  }
  return f(k);
}
int main() {
  int N;
  cin >> N;
  long long int S1 = 0, S2 = 0;
  for (int i = 1; i <= N; i++) {
    S1 += N / i;
  }
  long long int T[10];
  for (int i = 1; i < 10; i++) T[i] = N / 9;
  int M = N % 9;
  for (int i = 1; i <= M; i++) T[i]++;
  for (int i = 1; i <= 9; i++)
    for (int j = 1; j <= 9; j++) S2 += T[i] * T[j] * T[f(i * j)];
  cout << S2 - S1 << endl;
}
