import java.util.*

fun main(args: Array<String>) {
    val (N, M) = readLine()!!.split(" ").map{it.toInt()}

    val A = Array(N) { readLine()!!.split(" ").map{it.toInt()}}

    val st = TreeSet<Int>((1..M).toList())

    fun rec(): Int {
        val mp = TreeMap<Int, Int>()

        for (r in A) {
            val p = r.first { st.contains(it) }!!

            mp[p] = (mp[p] ?: 0) + 1
        }

        val e = mp.maxWith(Comparator<Map.Entry<Int, Int>> { a, b -> a.value - b.value })!!

        st.remove(e.key)

        if (st.isEmpty()) {
            return e.value
        } else {
            return Math.min(e.value, rec())
        }
    }

    println(rec())
}
