Example

Input

3


Output

1
#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 <utility>
#include <functional>
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
ll gcd(ll a, ll b){
    if(b==0) return a;
    return gcd(b, a%b);
}
ll lcm(ll a, ll b){
    return a/gcd(a, b)*b;
}
ll powmod(ll a, ll k, ll m){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=m;
        }
        ap=ap*ap;
        ap%=m;
        k>>=1;
    }
    return ans;
}
int main()
{
    ll n; cin>>n;
    vector<ll> fac;
    ll n0=n;
    for(ll i=2; i*i<=n0; i++){
        if(n0%i==0){
            int e=0;
            while(n0%i==0){
                n0/=i; e++;
            }
            if(e>1){
                cout<<-1<<endl;
                return 0;
            }
            fac.push_back(i);
        }
    }
    if(n0>1) fac.push_back(n0);
    if(fac.size()==1){
        cout<<1<<endl;
        return 0;
    }
    ll g=1;
    for(auto p:fac){
        g=lcm(g, p-1);
    }
    if(gcd(n, g)>1){
        cout<<-1<<endl;
        return 0;
    }
    vector<P> facd;
    ll g0=g;
    ll d=g;
    for(ll i=2; i*i<=g0; i++){
        if(g0%i==0){
            while(g0%i==0){
                g0/=i;
            }
            d/=i; d*=(i-1);
        }
    }
    if(g0>1) d=d/g0*(g0-1);
    ll d0=d;
    for(ll i=2; i*i<=d0; i++){
        if(d0%i==0){
            int e=0;
            while(d0%i==0){
                d0/=i; e++;
            }
            facd.push_back(P(i, e));
        }
    }
    if(d0>1) facd.push_back(P(d0, 1));
    ll ans=d;
    for(auto q:facd){
        ll p=q.first; int e=q.second;
        ll d1=d;
        for(int i=1; i<=e; i++){
            d1/=p;
            if(powmod(n, d1, g)!=1) break;
            ans/=p;
        }
    }
    cout<<ans<<endl;
    return 0;
}
