#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int m[300][300];
bool f[300];
int main()
{
	int num, kai;
	scanf("%d%d", &num, &kai);
	for (int i = 0; i < num; i++)
	{
		for (int j = 0; j < kai; j++)scanf("%d", &m[i][j]), m[i][j]--;
	}
	int mini = 1000000000;
	for (int p = 0; p < kai; p++)
	{
		int cnt[300];
		fill(cnt, cnt + kai, 0);
		for (int i = 0; i < num; i++)
		{
			for (int j = 0; j < kai; j++)
			{
				if (!f[m[i][j]])
				{
					cnt[m[i][j]]++;
					break;
				}
			}
		}
		int maxi = -1, rr = -1;
		for (int i = 0; i < kai; i++)if (maxi < cnt[i])maxi = cnt[i], rr = i;
		mini = min(mini, maxi);
		f[rr] = true;
	}
	printf("%d\n", mini);
}