#include <bits/stdc++.h>
using namespace std;
int d[1000001] = {0};
bool dnb[10][1000001] = {0};
int dn[10][111112] = {0};
long long dnSizes[10] = {0};
int main() {
  int n;
  cin >> n;
  int k = 0;
  for (int i = 1; i <= 1000000; i++) {
    k = (k % 9) + 1;
    d[i] = k;
    if (i <= n) {
      dnb[k][i] = 1;
      dn[k][dnSizes[k]++] = i;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      if (d[d[i] * d[j / i]] == d[j]) ans--;
    }
  }
  for (int i = 1; i <= min(9, n); i++) {
    for (int j = i; j <= min(9, n); j++) {
      if (i == j)
        ans += dnSizes[d[i * j]] * dnSizes[i] * dnSizes[j];
      else
        ans += 2 * dnSizes[d[i * j]] * dnSizes[i] * dnSizes[j];
    }
  }
  cout << ans << endl;
  return 0;
}
