#include <iostream>
#include <cstdio>
#define N 305
using namespace std;

int n, m, mx = 1e9, ans = 1e9, c[N], a[N][N];
bool v[N];
int main()
{
	int i, j;
	cin >> n >> m;
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
	}
	do {
		ans = min(ans, mx);
		mx = 0;
		for (i = 0; i < n; i++) {
			for (j = 0; j < m; j++) if (!v[a[i][j]]) break;
			c[a[i][j]]++;
		}
		for (i = 1; i <= m; i++) mx = max(mx, c[i]);
		for (i = 1; i <= m; c[i++] = 0) if (c[i] == mx) v[i] = 1;

	} while (mx);
    cout << ans << endl;
    return 0;
}