// Arup Guha
// 3/6/2021
// Solution to 2020 SER Problem: Exam Manipulation

import java.util.*;

public class exam {

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		int nQ = stdin.nextInt();
		int[] ans = new int[n];
		
		// Store results as a bitmask.
		for (int i=0; i<n; i++) {
			char[] line = stdin.next().toCharArray();
			for (int j=0; j<nQ; j++)
				ans[i] = line[j] == 'T' ? ((ans[i]<<1)+1) : (ans[i] << 1);
		}
		
		int res = 0;
		
		// Just try each answer key.
		for (int key=0; key<(1<<nQ); key++) {
		
			// Score each exam, finding min grade.
			int cur = nQ - Integer.bitCount(key^ans[0]);
			for (int i=1; i<n; i++)
				cur = Math.min(cur, nQ - Integer.bitCount(key^ans[i]));
			
			// Update our best result.
			res = Math.max(res, cur);
		}
		
		// Ta da!
		System.out.println(res);
	}
}