#include <bits/stdc++.h>
using namespace std;
int N;
int mod[1000001][9];
int main() {
  cin >> N;
  memset(&mod, 0, sizeof(mod));
  mod[1][1] = 1;
  for (int i = (int)(2); i <= (int)(N); ++i)
    for (int j = (int)(0); j <= (int)(8); ++j) {
      mod[i][j] = mod[i - 1][j];
      if (i % 9 == j) mod[i][j]++;
    }
  long long result = 0;
  for (int i = (int)(0); i <= (int)(8); ++i)
    for (int j = (int)(0); j <= (int)(8); ++j) {
      long long tmp = mod[N][(i * j) % 9];
      tmp *= mod[N][i];
      tmp *= mod[N][j];
      result += tmp;
    }
  for (int k = (int)(1); k <= (int)(N); ++k) result -= (N / k);
  cout << result;
  return 0;
}
