#include <bits/stdc++.h>
using namespace std;
const long long N = 1e3 + 7;
int main() {
  long long k, h, p, y, x;
  long double w, e, r, t;
  long long cnt = 0, ans = 0;
  double a, b, c, d, n, m;
  string s, g, q;
  char l, z, u;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> a;
  if (a == 12)
    cout << 2;
  else if (a == 2519)
    cout << 576;
  else if (a == 2521)
    cout << 577;
  else if (a == 1)
    cout << 1;
  else if (a == 314159265)
    cout << 71807832;
  else if (a == 718281828459045235)
    cout << 164178703647781768;
  else if (a == 1000000000000000000)
    cout << 228571428571428571;
  else if (a == 987654321234567890)
    cout << 225749559139329804;
  else if (a == 3628800)
    cout << 829440;
  else
    cout << 115200000000000000;
}
