#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const int lim = 1000000;
long long A[lim + 1], L[10], S[10], N;
int d(int num) {
  if (num % 9) return (num % 9);
  return 9;
}
int main() {
  cin >> N;
  for (int a = 1; a <= N; a++)
    for (int b = 1; a * b <= N; b++) A[a * b]++;
  for (int l = 1; l <= 9; l++) L[l] = (N - l + 9) / 9;
  for (int a = 1; a <= 9; a++)
    for (int b = 1; b <= 9; b++) S[d(a * b)] += L[a] * L[b];
  long long res = 0;
  for (int i = 1; i <= N; i++) res -= ((long long)A[i]);
  for (int i = 1; i <= 9; i++) res += ((long long)L[i] * (long long)S[i]);
  cout << res << endl;
  return 0;
}
