#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const int MAX=1000000;
bitset<MAX> isprime;
void sieve(){
	for(int i=3; i<MAX; i++, i++) isprime[i]=1;
	isprime[2]=1;
	for(int i=3; i<MAX; i++){
		if(isprime[i]){
			for(int j=(i<<1); j<MAX; j+=i) isprime[j]=0;
		}
	}
}
ll p[MAX];
ll n, sq;
int isq;
vector<ll> divs, pc;
inline ll idx(ll x){
	return (x<=sq)?x-1:(ll)divs.size()-n/x;
}
void calc(){
	sieve();
	while((sq+1)*(sq+1)<=n) sq++;
	for(int i=1; i<=sq; i++) divs.push_back(i);
	for(int i=sq; i>=1; i--) if(n/i>sq) divs.push_back(n/i);
	int k=0; isq=-1;
	for(int i=2; i<MAX; i++){
		if(isprime[i]){
            p[k]=i;
            if(i>sq && isq==-1) isq=k;
            k++;
		}
	}
}
void primecount(){
	vector<ll> dp=divs;
	pc.resize(divs.size(), -1);
	int l;
	for(l=0; l<divs.size() && divs[l]<p[0]*p[0]; l++){
		if(divs[l]<=1) pc[l]=0;
		else if(divs[l]==2) pc[l]=1;
		else pc[l]=2;
	}
	for(int i=1; i<=isq; i++){
		int r=lower_bound(divs.begin(), divs.end(), p[i]*p[i])-divs.begin();
		for(int j=(int)divs.size()-1; j>=l; j--){
			int k=idx(divs[j]/p[i-1]);
			if(pc[k]!=-1){
				dp[j]-=pc[k]-i+2;
			}else{
				dp[j]-=dp[k];
			}
		}
		for(int j=l; j<r; j++) pc[j]=dp[j]+i-1;
		l=r;
	}
}
ll solve(){
	vector<ll> dp(divs.size());
	for(int i=isq-1; i>=0; i--){//isqをisq-1に変更
		int l=lower_bound(divs.begin(), divs.end(), p[i]*(p[i]-1))-divs.begin();
		for(int j=(int)divs.size()-1; j>=l; j--){
            ll q=p[i]-1;
            ll a=dp[j];
            if(p[i+1]*(p[i+1]-1)>divs[j]){
                a=1+pc[j]-(i+1);
            }
            while(divs[j]>=q){
                ll x=divs[j]/q;
                int k=idx(x);
                ll b=dp[k];
                if(x<p[i+1]-1) b=1;
                else if(p[i+1]*(p[i+1]-1)>x){
                    b=1+pc[k]-(i+1);
                }
                a+=b;
                q*=p[i];
            }
			dp[j]=a;
		}
	}
    dp[0]=2;
	return dp.back();
}
ll powmod(__int128_t a, ll k, ll m){
	__int128_t ap=a, ans=1;
	while(k){
		if(k&1){
			ans*=ap;
			ans%=m;
		}
		k>>=1;
		ap=ap*ap%m;
	}
	return ans;
}
bool is_prime(ll n){
    if(n<MAX) return isprime[n];
	if(n<=1 || !(n&1)) return (n==2);
	ll d=n-1;
	int k=0;
	while(!(d&1)){
		d>>=1;
		k++;
	}
	vector<ll> va{2, 325, 9375, 28178, 450775, 9780504, 1795265022}; // http://miller-rabin.appspot.com/
	for(auto aa:va){
		ll a=aa%n;
		if(a==0) continue;
		bool comp=1;
		ll ap=powmod(a, d, n);
		if(ap==1 || ap==n-1) continue;
		for(int r=1; r<k; r++){
			ap=(__int128_t)ap*ap%n;
			if(ap==n-1){
				comp=0;
				break;
			}
		}
		if(comp) return false;
	}
	return true;
}
int main()
{
	cin>>n;
	calc();
	primecount();
    for(int i=0; i<divs.size(); i++){
        if(is_prime(divs[i]+1)) pc[i]++;
    }
	cout<<solve()<<endl;
	return 0;
}