fn main() { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); let n: u64 = s.trim().parse().unwrap(); let f = |x: u64| { let mut i = 1u64; while x.pow(i as u32) < n { i += 1; } x * i }; println!("{}", f(2).min(f(3)).min(f(5))) }