#include #define LL long long LL sum(LL x); int main(void) { LL n; scanf("%lld", &n); for (LL i = n; i >= 1; i--) { if ((sum(n) * (n / i) + sum(n % i)) % i == 0) { printf("%lld\n", i); break; } } return 0; } LL sum(LL x) { return (1 + x) * x / 2; }