use std::cmp::max; use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: u64 = itr.next().unwrap().parse().unwrap(); let m = n * (n + 1) / 2; let mut ans = 0; let mut i = 1; while i * i <= n { if n % i == 0 { if m % i == 0 { ans = max(ans, i); } if m % (n / i) == 0 { ans = max(ans, n / i) } } i += 1; } println!("{}", ans); }