#include <bits/stdc++.h>
long long int N;
long long int l[9 * 9 * 9 + 1][3];
int digroot(int x) {
  x = x % 9;
  if (x == 0)
    return 9;
  else
    return x;
}
long long findit(long long int a, long long int N) {
  if (a == 0)
    return (N - a) / 9;
  else
    return 1 + (N - a) / 9;
}
int main() {
  long long int a, b, c;
  int i;
  long long answer = 0;
  int ct = 0;
  for (a = 0; a < 9; a++)
    for (b = 0; b < 9; b++)
      for (c = 0; c < 9; c++) {
        if (digroot(a * b) == digroot(c)) {
          l[ct][0] = a;
          l[ct][1] = b;
          l[ct][2] = c;
          ct++;
        }
      }
  scanf("%lld", &N);
  for (i = 0; i < ct; i++) {
    a = l[i][0];
    b = l[i][1];
    c = l[i][2];
    if (N >= a && N >= b && N >= c) {
      answer += findit(a, N) * findit(b, N) * findit(c, N);
    }
  }
  for (a = 1; a <= N; a++)
    for (c = a; c <= N; c += a) {
      answer--;
    }
  printf("%lld\n", answer);
}
