integer N,M
integer,allocatable,dimension(:,:)::A
logical,allocatable,dimension(:)::SPORTS
integer,allocatable,dimension(:)::CONTESTANTS
integer ans,preans
read*,N,M
allocate(A(N,M))
do i=1,N
  read*,A(i,:)
end do

allocate(SPORTS(M),CONTESTANTS(M))
SPORTS=.TRUE.

ans=huge(ans)

do i=1,M
  CONTESTANTS=0
  do j=1,N
    do k=1,M
      if(SPORTS(A(j,k)))then
        CONTESTANTS(A(j,k))=CONTESTANTS(A(j,k))+1
        exit
      endif
    end do
  end do
  preans=maxval(CONTESTANTS)
  do j=1,M
    if(CONTESTANTS(j)==preans)then
      SPORTS(j)=.FALSE.
      exit
    endif
  end do
  ans=min(ans,preans)
end do

print"(I0)",ans

end