#include <bits/stdc++.h>
using namespace std;
long long int s(long long int x) {
  long long int ret = 0;
  while (x != 0) {
    ret += x % 10;
    x /= 10;
  }
  return ret;
}
long long int d(long long int x) {
  if (x <= 9)
    return x;
  else
    return d(s(x));
}
bool isprime[1000005];
long long int spf[1000005];
void sieve() {
  for (long long int i = 2; i < 1000005; i++) {
    if (spf[i] == 0) {
      for (long long int j = i; j < 1000005; j += i) {
        if (spf[j] == 0) spf[j] = i;
      }
    }
  }
}
long long int num_divisors(long long int n) {
  map<long long int, long long int> ma;
  while (n != 1) {
    ma[spf[n]]++;
    n = n / spf[n];
  }
  long long int ret = 1;
  for (auto i : ma) ret *= (1 + i.second);
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    long long int n;
    cin >> n;
    long long int arr[10];
    memset(arr, 0, sizeof(arr));
    for (long long int i = 1; i <= n; i++) arr[d(i)]++;
    long long int ans = 0;
    for (long long int i = 1; i <= 9; i++) {
      for (long long int j = 1; j <= 9; j++) {
        ans += arr[i] * arr[j] * arr[d(i * j)];
      }
    }
    sieve();
    for (long long int i = 1; i <= n; i++) ans -= num_divisors(i);
    cout << ans;
  }
  return 0;
}
