#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  vector<ll> v(9);
  for (int i = 0; i < 9; i++) v[i] = (n + 9 - i) / 9;
  v[0]--;
  ll ans = 0;
  for (ll i = 1; i <= n; i++) {
    for (ll j = 1; i * j <= n; j++) ans--;
  }
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      ans += v[i] * v[j] * v[(i * j) % 9];
    }
  }
  cout << ans;
}
