#include <bits/stdc++.h>
using namespace std;
const int mxn = (1 << 20);
int sum[mxn];
int root[mxn];
int rcnt[16];
int Z[10][10][10];
int main() {
  int N;
  cin >> N;
  long long sol = 0;
  for (int i = 1; i < mxn; i++) {
    sum[i] = sum[i / 10] + (i % 10);
    if (sum[i] <= 9)
      root[i] = sum[i];
    else
      root[i] = root[sum[i]];
  }
  for (int A = 1; A <= N; A++) {
    rcnt[root[A]]++;
    for (int C = A, B = 1; C <= N; B++, C += A) {
      Z[root[A]][root[B]][root[C]]++;
    }
  }
  for (int rc = 1; rc <= 9; rc++)
    for (int ra = 1; ra <= 9; ra++)
      for (int rb = 1; rb <= 9; rb++)
        if (root[ra * rb] == rc) {
          long long x = rcnt[ra] * (long long)rcnt[rb] * (long long)rcnt[rc] -
                        Z[ra][rb][rc];
          sol += x;
        }
  cout << sol << endl;
  return 0;
}
