#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  os << "{" << p.first << ", " << p.second << "}";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& p) {
  os << "[";
  int i = 0;
  for (typename vector<T>::const_iterator it = p.begin(); it != p.end(); ++it) {
    os << (i == 0 ? "" : ", ") << *it;
    i++;
  }
  os << "]";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& p) {
  os << "[";
  int i = 0;
  for (typename set<T>::const_iterator it = p.begin(); it != p.end(); ++it) {
    os << (i == 0 ? "" : ", ") << *it;
    i++;
  }
  os << "]";
  return os;
}
template <class K, class V>
ostream& operator<<(ostream& os, const map<K, V>& p) {
  os << "[";
  int i = 0;
  for (typename map<K, V>::const_iterator it = p.begin(); it != p.end(); ++it) {
    os << (i == 0 ? "" : ", ") << *it;
    i++;
  }
  os << "]";
  return os;
}
template <class T>
string toString(const T& o) {
  stringstream ss;
  ss << o;
  string ret;
  getline(ss, ret);
  return ret;
}
template <class T>
vector<T> subv(const vector<T>& v, int from, int to) {
  return vector<T>(v.begin() + min(max(0, from), (int)v.size()),
                   v.begin() + min(max(0, to), (int)v.size()));
}
pair<int, int> operator+(const pair<int, int>& a, const pair<int, int>& b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
pair<int, int> operator*(const int& a, const pair<int, int>& b) {
  return make_pair(a * b.first, a * b.second);
}
int digroot(int n) {
  if (n <= 9) return n;
  int r = 0;
  while (n) {
    r += n % 10;
    n /= 10;
  }
  return digroot(r);
}
int mul[10][10];
int main() {
  int n;
  cin >> n;
  vector<int> dels(n + 1, 0);
  vector<int> root(n + 1, -1);
  vector<long long> stat(10, 0);
  for (int i = 1; i <= 9; ++i)
    for (int j = 1; j <= 9; ++j) mul[i][j] = digroot(i * j);
  for (int i = 1; i <= n; ++i) {
    root[i] = digroot(i);
    stat[root[i]]++;
    int j = i;
    while (j <= n) {
      dels[j]++;
      j += i;
    }
  }
  long long cnt = 0;
  for (int k = 1; k <= n; ++k) {
    long long num = 0;
    for (int i = 1; i <= 9; ++i)
      for (int j = 1; j <= 9; ++j)
        if (mul[i][j] == root[k]) num += stat[i] * stat[j];
    long long add = num - dels[k];
    assert(add >= 0);
    cnt += add;
  }
  cout << cnt << endl;
  return 0;
}
