#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using uint = unsigned int;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(11) << fixed;
  int n;
  cin >> n;
  vector<int> root(max(n, 9 * 9) + 1);
  for (int i = 1; i <= max(n, 9 * 9); ++i) {
    root[i] = root[i - 1] + 1;
    if (root[i] == 10) {
      root[i] = 1;
    }
  }
  vector<vector<int>> sums(n + 1);
  sums[0] = vector<int>(10);
  for (int i = 1; i <= n; ++i) {
    sums[i] = sums[i - 1];
    ++sums[i][root[i]];
  }
  ll ans = 0;
  for (int a = 1; a <= n; ++a) {
    for (int d = 1; d < 10; ++d) {
      ans += ll(sums[n / a][d]) * max(0, sums[n][root[root[a] * d]] - 1) +
             ll(sums[n][d] - sums[n / a][d]) * sums[n][root[root[a] * d]];
    }
  }
  cout << ans << '\n';
  return 0;
}
