#![allow(unused_imports)] #![allow(non_snake_case)] use std::collections::HashMap; use std::collections::HashSet; #[allow(unused_macros)] macro_rules! read { ([$t:ty] ; $n:expr) => ((0..$n).map(|_| read!([$t])).collect::>()); ($($t:ty),+ ; $n:expr) => ((0..$n).map(|_| read!($($t),+)).collect::>()); ([$t:ty]) => (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::>()); ($t:ty) => (rl().parse::<$t>().unwrap()); ($($t:ty),*) => {{ let buf = rl(); let mut w = buf.split_whitespace(); ($(w.next().unwrap().parse::<$t>().unwrap()),*) }}; } #[allow(dead_code)] fn rl() -> String { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).unwrap(); buf.trim_end().to_owned() } fn main() { let n = read!(usize); let m = min_factor(n); if m == n || m >= 3{ println!("{}", m); } else { let m2 = min_factor(n/m); println!("{}", m2.min(m * m2)); } } fn min_factor(n: usize) -> usize { for p in primes((n as f64).sqrt() as usize + 1).iter() { if n % p == 0 { return *p; } }; n } fn primes(n: usize) -> Vec:: { if n < 2 { return vec![]; } let mut table = vec![true; n+1]; table[0] = false; table[1] = false; for i in 2..=(n as f64).sqrt() as usize { if table[i] == false { continue; } let mut j = i*i; while j <= n { table[j] = false; j += i; } } table .iter() .enumerate() .filter(|(_, &flg)| flg) .map(|(num, _)| num) .collect() }