#include <bits/stdc++.h>
using namespace std;
long long t[10];
int a[1000001];
int f(long long x) {
  long long res = 0;
  while (x > 0) {
    res += x % 10;
    x /= 10;
  }
  return (res < 10) ? res : f(res);
}
int main() {
  long long N, ans1 = 0, ans2 = 0;
  cin >> N;
  for (long long i = 1; i <= N; ++i) ++t[a[i] = f(i)];
  cerr << '!';
  for (int i = 0; i < 10; ++i)
    for (int j = 0; j < 10; ++j)
      for (int k = 0; k < 10; ++k)
        if (f(i * j) == k) ans2 += t[i] * t[j] * t[k];
  for (long long i = 1; i <= N; ++i)
    for (long long j = 1; j <= N && i * j <= N; ++j) ++ans1;
  cerr << ans1 << ' ' << ans2 << endl;
  cout << ans2 - ans1 << endl;
  return 0;
}
