#include <iostream>
#include <vector>
#include <unordered_map>
#include <string>
#include <algorithm>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
cin.ignore(); // 忽略换行符
vector<string> arr(n);
for (int i = 0; i < n; ++i) {
getline(cin, arr[i]); // 读取 n 行字符串
}
unordered_map<string, int> columns;
// 构建每一列的字符串并统计出现次数
for (int j = 0; j < m; ++j) {
string col;
for (int i = 0; i < n; ++i) {
col += arr[i][j]; // 组合列字符串
}
columns[col]++; // 统计列字符串出现次数
}
// 找到出现次数的最大值
int total_max = 0;
for (const auto& entry : columns) {
total_max = max(total_max, entry.second);
}
cout << total_max << endl; // 输出最大出现次数
return 0;
}