#include <bits/stdc++.h>
using namespace std;
int getd(int a) {
  int ret = 0;
  while (a > 0) {
    ret += a % 10;
    a /= 10;
  }
  return ret;
}
int isp[1000001];
void getp() {
  memset(isp, 1, sizeof(isp));
  for (int i = 2; i <= 1000000; i++) {
    if (isp[i] == 0) continue;
    for (int j = i + i; j <= 1000000; j += i) isp[j] = 0;
  }
  return;
}
int main() {
  int N;
  cin >> N;
  int droot[N + 1];
  droot[0] = 0;
  int cnt[10];
  memset(cnt, 0, sizeof(cnt));
  getp();
  unsigned long long facts = 0;
  for (int i = 1; i <= N; i++) {
    if (i < 10)
      droot[i] = i;
    else
      droot[i] = droot[getd(i)];
    if (droot[i] >= 10 || droot[i] == 0)
      cout << "\"FCUK\""
           << ": "
           << "FCUK" << endl;
    ;
    cnt[droot[i]]++;
    int ni = i;
    int tfacts = 1;
    for (int j = 2; j <= ni; j++) {
      if (isp[ni]) {
        tfacts *= 2;
        break;
      }
      if (ni % j == 0) {
        int cfact = 0;
        while (ni % j == 0) {
          cfact++;
          ni /= j;
        }
        tfacts *= (cfact + 1);
      }
    }
    facts += tfacts;
  }
  unsigned long long ret = 0;
  for (int first = 1; first < 10; first++) {
    for (int second = 1; second < 10; second++) {
      unsigned long long nf = cnt[first];
      unsigned long long ns = cnt[second];
      if (nf == 0 || ns == 0) continue;
      int prod = first * second;
      while (prod >= 10) {
        prod = getd(prod);
      }
      unsigned long long np = cnt[prod];
      if (np == 0) continue;
      unsigned long long ways = nf * ns * np;
      ret += ways;
    }
  }
  cout << (ret - facts) << endl;
  return 0;
}
