fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut boxes = (0..n).map(|_| { let mut temp = String::new(); std::io::stdin().read_line(&mut temp).ok(); let mut temp: Vec = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); temp.sort(); (temp[2], temp[1], temp[0]) }) .collect::>(); boxes.sort(); let mut result = vec![1usize; n]; for i in 1..n { let (x, y, z) = boxes[i]; for j in 0..i { let (px, py, pz) = boxes[j]; if x > px && y > py && z > pz { result[i] = result[i].max(1 + result[j]); } } } println!("{}", result.iter().max().unwrap()); }