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 ans = 0; let mut vs = vec![]; solve(&mut ans, &mut vs, 0, n, false); println!("{}", ans); } fn solve(ans: &mut usize, vs: &mut Vec, sum: usize, i: usize, even: bool) { if i < 2 { if sum > *ans { *ans = sum; } return; } let mut ok = true; for &v in vs.iter() { if gcd(i, v) != 1 { ok = false; break; } } if ok { vs.push(i); if i % 2 == 0 { solve(ans, vs, sum + i, i - 1, true); } else if even { solve(ans, vs, sum + i, i - 2, even); } else { solve(ans, vs, sum + i, i - 1, even); } vs.pop(); } if even { solve(ans, vs, sum, i - 2, even); } else { solve(ans, vs, sum, i - 1, even); } } // doc.rust-lang.org/std/ops/trait.Div.html fn gcd(x: usize, y: usize) -> usize { let mut x = x; let mut y = y; while y != 0 { let t = y; y = x % y; x = t; } x }