import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class 실험실 {
    static int N;
    static int K;
    static int count = 0 ;
    static boolean[][] word;
    static boolean[] visit = new boolean[26];;
    public static void main(String[] args) throws Exception{
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	StringTokenizer st = new StringTokenizer(br.readLine());
        N = Integer.parseInt(st.nextToken()); 
        K = Integer.parseInt(st.nextToken()); 
        if(K < 5) {
        	System.out.print(0);  
        	return ;
        }
        word = new boolean[N][26]; 
        
        
        for (int i = 0; i < N; i++) {
            String temp = br.readLine();
            for (char c : temp.toCharArray()) {
                word[i][c - 'a'] = true;
            }
        }
        
        perm(0, 0);
        System.out.print(count);
    }
    private static void perm(int index, int depth) {
    	
    	
        if (depth == K) {
            check();  
            return;
        }
        
        for (int i = index; i < 26; i++) {
            if (!visit[i]) {
                visit[i] = true;
                perm(i, depth + 1);
                visit[i] = false;
            }
        }
    }
    private static void check() {
        int max = 0;
        boolean b ;
        for (int i = 0; i < N; i++) {
        	b= true;
            for (int j = 0; j < 26; j++) {
                if (word[i][j] && !visit[j]) { 
                	b= false;
                    break;
                }
            }
            if(b) max++;
        }
        count = Math.max(max, count);
    }
}
