#include <iostream>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
int rows;
int bottles;
int year;
int best_year;
cin >> rows >> bottles >> best_year;
for (int row = 2; row <= rows && row < bottles + 2; ++row) {
for (int col = 1; col <= row; ++col) {
cin >> year;
if (best_year > year) {
int dep = row * (row - 1) / 2;
if(col >= 3){
dep -= (col - 1) * (col - 2) / 2;
}
if(row - col >= 2) {
dep -= (row - col) * (row - col - 1) / 2;
}
if(dep < bottles){
best_year = year;
}
}
}
}
cout << best_year << endl;
return 0;
}