use std::io::{stdin, Read}; 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 xs = vec![false; n + 1]; let mut ys = vec![]; for i in 2..xs.len() { if xs[i] { continue; } ys.push(i); for j in 2..xs.len() { if i * j >= xs.len() { break; } xs[i*j] = true; } } let mut ans: usize = ys.iter().sum(); if let Some(s) = ys.iter().filter(|&y| y * 2 <= n).last() { ans += s; } println!("{}", ans - 2); }