use std::collections::HashSet; fn main() { let (n, k) = { let mut line = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( iter.next().unwrap().parse::().unwrap(), iter.next().unwrap().parse::().unwrap(), ) }; let mut ccc: Vec> = vec![]; for _ in 0..n { let mut line = String::new(); std::io::stdin().read_line(&mut line).unwrap(); ccc.push(line.trim().chars().collect()); } let sss: Vec> = ccc .iter() .map(|cc| cc.iter().map(|&c| (c as u8 - b'0') as usize).collect()) .collect(); let mut min_max = vec![0; 1 << k]; let mut min_max_indexes = vec![0; 1 << k]; for i in 0..n { for bit in 1..(1 << k) { let min = (0..k) .filter(|&j| (bit >> j) & 1 == 1) .map(|j| sss[i][j]) .min() .unwrap(); if min >= min_max[bit] { min_max[bit] = min; min_max_indexes[bit] = i; } } } let mut s = HashSet::new(); for &e in min_max_indexes.iter().skip(1) { s.insert(e); } let ans = n - s.len(); println!("{}", ans); }