const INF: i32 = 1010101010; fn main() { use std::cmp::max; let n: usize = input(); let p = primes(n + 1); let m = p.len(); let mut dp = vec![[-INF; 20001]; m + 1]; dp[0][0] = 0; for i in 0..m { for j in 0..n + 1 { dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]); if j + p[i] <= n { dp[i + 1][j + p[i]] = max(dp[i + 1][j + p[i]], dp[i][j] + 1); } } } if dp[m][n] >= 0 { println!("{}", dp[m][n]); } else { println!("-1"); } } fn primes(n: usize) -> Vec { let mut res = Vec::new(); let mut table = vec![true; n]; for i in 2..n { if table[i] { res.push(i); let mut j = i * 2; while j < n { table[j] = false; j += i; } } } res } fn input() -> T { use std::io::Read; let stdin = std::io::stdin(); let stdin = stdin.bytes(); let token = stdin .skip_while(|x| (*x.as_ref().unwrap() as char).is_whitespace()) .take_while(|x| !(*x.as_ref().unwrap() as char).is_whitespace()) .map(|x| x.unwrap()) .collect(); let token = String::from_utf8(token).unwrap(); match token.parse() { Ok(x) => x, Err(_) => panic!("{}", token), } }