#include <bits/stdc++.h>
using namespace std;
int d(int x) {
  if (x <= 9) return x;
  int sum = 0;
  while (x > 0) {
    sum += x % 10;
    x /= 10;
  }
  return d(sum);
}
int ile[1000100][10];
vector<pair<int, int> > P[10];
int main() {
  int n;
  long long ret = 0;
  scanf("%d", &n);
  for (int A = (1); A <= (n); A++) {
    for (int B = (1); B <= (n); B++) {
      if (A * B > n) break;
      ret--;
    }
  }
  for (int i = (1); i <= (n); i++) ile[i][d(i)]++;
  for (int i = (1); i <= (n); i++)
    for (int j = (1); j <= (9); j++) ile[i][j] += ile[i - 1][j];
  for (int i = (1); i <= (9); i++) {
    for (int a = (1); a <= (9); a++)
      for (int b = (1); b <= (9); b++) {
        if (d(d(a) * d(b)) == i) P[i].push_back(make_pair(a, b));
      }
  }
  for (int i = (1); i <= (n); i++) {
    int target = d(i);
    for (int i = (0); i < (((int)(P[target]).size())); i++)
      ret += (long long)ile[n][P[target][i].first] *
             (long long)ile[n][P[target][i].second];
  }
  cout << ret;
}
