use std::io::{Read, stdin}; fn main() { let mut buf = String::new(); stdin().read_to_string(&mut buf).unwrap(); let mut tok = buf.split_whitespace(); let mut get = || tok.next().unwrap(); macro_rules! get { ($t:ty) => (get().parse::<$t>().unwrap()); () => (get!(usize)); } let n = get!(); let mut qs = vec![]; let mut ps = vec![]; let mut flag = vec![false; n * 3 + 1]; for i in 2..flag.len() { if flag[i] { continue; } if i <= n { qs.push(i); } ps.push(i); for j in 2..flag.len() { let k = i * j; if k >= flag.len() { break; } flag[k] = true; } } let mut tb = vec![vec![]; n * 2 + 1]; for i in 1..qs.len() { let q1 = qs[i]; for j in i+1..qs.len() { let q2 = qs[j]; tb[q1+q2].push(q2); } } let mut ans = 0_i64; for i in 3..tb.len() { if tb[i].len() == 0 { continue; } tb[i].sort(); for &q in qs.iter() { if flag[q+i] { continue; } let mut lp = 0; let mut rp = tb[i].len(); while lp < rp { let hp = (lp + rp) / 2; if tb[i][hp] >= q { rp = hp; } else { lp = hp + 1; } } ans += rp as i64; } } println!("{}", ans); }