#include <bits/stdc++.h>
const int N = 1000000 + 10;
const int M = 10;
int d[N];
int cnt[M];
int D(int x) {
  if (d[x] >= 0) return d[x];
  d[x] = 0;
  int y = 0, z = x;
  while (z) {
    y += z % 10;
    z /= 10;
  }
  if (y < 10)
    d[x] = y;
  else
    d[x] = D(y);
  return d[x];
}
int main() {
  memset(d, -1, sizeof d);
  int n;
  scanf("%d", &n);
  memset(cnt, 0, sizeof cnt);
  for (int i = 1; i <= n; ++i) ++cnt[D(i)];
  long long ans = 0, v;
  for (int c = 1; c <= n; ++c) {
    for (int j = 1; j <= n; ++j) {
      if (c * j <= n)
        --ans;
      else
        break;
    }
    for (int j = 1; j < 10; ++j)
      for (int k = 1; k <= j; ++k)
        if (D(j * k) == D(c)) {
          if (j == k)
            ans += (long long)cnt[j] * cnt[k];
          else
            ans += (long long)cnt[j] * cnt[k] * 2;
        }
  }
  std::cout << ans << std::endl;
  return 0;
}
