fn main() { let stdin = std::io::read_to_string(std::io::stdin()).unwrap(); let mut stdin = stdin.split_ascii_whitespace(); let x: u64 = stdin.next().unwrap().parse().unwrap(); let y: u64 = stdin.next().unwrap().parse().unwrap(); let z: u64 = stdin.next().unwrap().parse().unwrap(); println!("{}", output(solve(x, y, z))); } fn solve(x: u64, y: u64, z: u64) -> u64 { if z < x { z } else if z < y { z - 1 } else { z - 2 } } fn output(ans: u64) -> u64 { ans }