local n, m = io.read("*n", "*n") local cnt = {} for i = 1, n do cnt[i] = 0 end local score, name = {}, {} for i = 1, m do score[i] = 0 name[i] = {} end local ret = 0 for i = 1, n do for j = 1, m do local rij = io.read("*n") if score[j] == rij then table.insert(name[j], i) cnt[i] = cnt[i] + 1 if cnt[i] == 1 then ret = ret + 1 end elseif score[j] < rij then for k = 1, #name[j] do local z = name[j][k] cnt[z] = cnt[z] - 1 if cnt[z] == 0 then ret = ret - 1 end end score[j] = rij name[j] = {i} cnt[i] = cnt[i] + 1 if cnt[i] == 1 then ret = ret + 1 end end end print(ret) end