#include <bits/stdc++.h>
using namespace std;
long long n, ans, sz[1000006];
long long js(long long fk) { return (fk - 1) % 9 + 1; }
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    sz[js(i)]++;
  }
  for (int i = 1; i <= 9; i++) {
    for (int j = 1; j <= 9; j++) {
      for (int k = 1; k <= 9; k++) {
        if (i * j % 9 == k % 9) {
          ans += sz[i] * sz[j] * sz[k];
        }
      }
    }
  }
  for (int l = 1, r; l <= n; l = r + 1) {
    r = min(n, n / (n / l));
    ans -= n / l * (r - l + 1);
  }
  cout << ans << endl;
  return 0;
}
