#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
using LL = int64_t;
LL num[20];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  LL ans = 0;
  for (int i = 1; i <= n; i++) {
    num[1 + (i - 1) % 9]++;
    ans -= n / i;
  }
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      ans += num[i] * num[j] * num[1 + (i * j - 1) % 9];
    }
  }
  cout << ans << endl;
  return 0;
}
