#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int ans[10] = {0}, j = min(n, 9), t;
  long long re = 0;
  for (int i = 1; i <= j; ++i) ans[i] = (n - i) / 9 + 1;
  for (int i = 1; i <= j; ++i) {
    for (int k = 1; k <= j; ++k) {
      re += (long long)ans[i] * ans[k] * ans[(t = (i * k) % 9) == 0 ? 9 : t];
    }
  }
  for (int i = 1; i <= n; ++i) re -= n / i;
  printf("%I64d\n", re);
  return 0;
}
