Example

Input

3


Output

1
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll N;

ll mod_pow(ll x,ll n, ll mod){

	if(n == 0)return 1;
	ll ret = mod_pow(x*x%mod,n/2,mod);
	if(n%2 == 1)ret = ret*x%mod;
	return ret;
}

ll euler(ll num){

	 ll ret = num;

	 for(ll i = 2; i*i <= num;  i++){
			if(num%i == 0) {
				  ret  = ret/i*(i-1);
				  while(num%i == 0)num /= i;
			}
	  }
	  if(num != 1) ret = ret/num*(num-1);
	  return ret;
}

ll gcd(ll x,ll y){
	if(x < y){

		swap(x,y);
	}

	if(y == 0){
		return x;
	}else{
		return gcd(y,x%y);
	}
}


int main(){

	scanf("%lld",&N);

	vector<ll> V;

	ll work_N = N;

	for(ll i = 2; i*i <= N; i++){

		if(work_N%i == 0){

			V.push_back(i);

			int count = 0;

			while(work_N%i == 0){
				work_N /= i;
				count++;
			}

			if(count >= 2){

				printf("-1\n");
				return 0;
			}
		}
	}

	if(work_N != 1){
		V.push_back(work_N);
	}

	ll L = 1;

	for(int i = 0; i < V.size(); i++){

		ll common = gcd(L,V[i]-1);
		L = L*(V[i]-1)/common;
	}

	if(gcd(L,N) != 1){

		printf("-1\n");
		return 0;
	}

	ll number = euler(L),ans = L;

	for(ll k = 1; k <= number; k++){

		if(number%k != 0)continue;

		if(mod_pow(N,k,L) == 1){

			ans = k;
			break;
		}
	}

	printf("%lld\n",ans);

	return 0;
}

