use std::cmp::min; fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut result = if n > 4 && n % 2 == 0 { n / 2 } else { n }; for i in 3..=min(result, 1000000) { if n % i == 0 { result = i; break; } } println!("{}", result); }