#include #include #include #include #include #include #include #include #include #include #include #define REP(i, n) for(int i = 0;i < n;i++) #define REPR(i, n) for(int i = n;i >= 0;i--) #define FOR(i, m, n) for(int i = m;i < n;i++) #define FORR(i, m, n) for(int i = m;i >= n;i--) #define SORT(v, n) sort(v, v+n); #define VSORT(v) sort(v.begin(), v.end()); #define llong long long #define pb(a) push_back(a) using namespace std; typedef long long int ll; typedef pair pii; typedef pair pll; /* template vector make_v(size_t a) { return vector(a); } template auto make_v(size_t a, Ts... ts) { return vector(ts...))>(a, make_v(ts...)); } template typename enable_if::value == 0>::type fill_v(T& t, const V& v) { t = v; } template typename enable_if::value != 0>::type fill_v(T& t, const V& v) { for (auto& e : t) fill_v(e, v); } */ #define ARRAY_MAX 100005 const ll INF = 1e9; const ll MOD = 1e9 + 7; int dx[4] = { 1,0,0,-1 }; int dy[4] = { 0,1,-1,0 }; /******************************************************************************************/ //約数の列挙 template vector divisor(T n) { vector res; for (T i = 1; i * i <= n; i++) { if (n % i == 0) { res.push_back(i); if (i != n / i) { res.push_back(n / i); } } } return res; } //ユークリッド互除法 template T gcd(T x, T y) { if (y == 0) { return x; } else { return gcd(y, x % y); } } int main() { ll n, k; cin >> n >> k; vector div = divisor(n); ll maxi = 1LL; sort(div.begin(), div.end()); for (int i = 1; i < div.size()-1; i++) { maxi = max(maxi, gcd(div[i], n - div[i])); } cout << maxi << endl; return 0; }