#include <iostream>
#include <unordered_map>
using namespace std;
int main() {
int m, n;
cin >> m >> n;
const int total = m * n;
int x;
unordered_map<int, int> h;
for (int i = 0; i < total; ++i) {
cin >> x;
if (++h[x] * 2 > total) {
cout << x << endl;
break;
}
}
return 0;
}