#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const int MOD = 1000000007; typedef unsigned long long ull; int main() { ull N; cin >> N; ull sum = 0ull; for (ull i = 0; i < N; ++i) { sum += i; } ull r; if( N < sum ) { r = N; N = sum; sum = r; } //ユークリッドの互除法により最大公約数を求める while( (r = N % sum) != 0 ) { N = sum; sum = r; } // sumが答え cout << sum << endl; }