#include <bits/stdc++.h>
using namespace std;
int main() {
int a,i,j,h,g,n,w,l,z;
ios_base::sync_with_stdio(false);
cin.tie(NULL);
j=1;
h=1;
l=0;
z=2;
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin>>n>>a;
vector <int> t((n*(n+1))/2);
vector <int> d(2021);
vector <int> x(n);
for(i=1; i<(((n*(n+1))/2)+1);i++) {
cin>>g;
t[i]=g;
x[i]=j;
if(h==j) {
j++;
h=0;
}
h++;
if(d[t[i]]==0) d[t[i]]=i;
}
sort(t.begin(),t.end());
i=1;
while(1) {
if(x[d[t[i]]]!=x[d[t[i]]+1]) {
if(x[d[t[i]]]<=n) {
w=t[i];
break;
}
}
else{
if(x[d[t[i]]]>x[d[t[i]]-x[d[t[i]]]]) {
d[t[i]]=d[t[i]]-x[d[t[i]]];
l+=z;
z++;
}
else {
d[t[i]]=d[t[i]]-x[d[t[i]]]+1;
l+=z;
z++;
}
}
if(l>n) i++;
}
cout<<w;
return 0;
}