#include<cstdio>
using namespace std;
int n,m,k,ans;
int a[305][305],b[305];
bool ban[305];
int main(){
	scanf("%d%d", &n, &m);
	for( int i = 1; i <= n; i++ )
	for( int j = 1; j <= m; j++ )
	scanf("%d", &a[i][j]);
	ans = n;
	for( int i = 1; i <= m; i++ ){
		for( int j = 1; j <= m; j++ ) b[j] = 0;
		for( int j = 1; j <= n; j++ )
		for( int k = 1; k <= m; k++ )
		if( !ban[a[j][k]] ) {
			++b[a[j][k]]; break;
		}
		for( int j=k=1; j <= m; j++ ) if( b[j] > b[k] ) k = j;
		ban[k] = true;
		if( b[k] < ans ) ans = b[k];
	}
	printf("%d\n", ans);
	return 0;
}