import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val m = scanner.nextInt()
//    val A = Array(n,{IntArray(m)})
    val A = mutableListOf<MutableList<Int>>()
    var t:IntArray

    val maxArray = IntArray(m)

    for (i in 0..n - 1) {
        A.add(mutableListOf<Int>())
        for (j in 0..m - 1) {
            A[i].add(scanner.nextInt())
        }
    }

    for (i in 0..m - 1) {
        t = IntArray(m)
        for (j in 0..n - 1) {
            t[A[j][0]-1]++
        }

        maxArray[i] = t.max() as Int

        for (j in 0..n - 1) {
            A[j].remove(t.indexOf(t.max() as Int) + 1)
        }
    }

    println(maxArray.min())
}