#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<long long> ar(9, n / 9);
  for (int i = 1; i <= n % 9; i++) ar[i]++;
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    int temp = n / i;
    vector<long long> k(9, temp / 9);
    for (int j = 1; j <= temp % 9; j++) {
      k[j]++;
    }
    for (int j = 0; j < 9; j++) {
      res += k[j] * (ar[(i * j) % 9] - 1);
    }
    for (int j = 0; j < 9; j++) {
      k[j] = ar[j] - k[j];
    }
    for (int j = 0; j < 9; j++) {
      res += k[j] * ar[(i * j) % 9];
    }
  }
  cout << res << "\n";
  return 0;
}
