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 dp = vec![1usize; n]; for i in 1..n { let (rx, ry, rz) = boxes[i]; for j in 0..i { let (lx, ly, lz) = boxes[j]; if lx < rx && ly < ry && lz < rz { dp[i] = dp[i].max(dp[j]+1); } } } println!("{}", dp.iter().max().unwrap()); }