#include <iostream>
#include <vector>
//#include <fstream>
//#include <Windows.h>
using namespace std;
vector <int> piramida[2001];
vector <int> butle[2001];
int main()
{
//fstream f;
//f.open("tesst.txt", ios::in);
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k;
int ilosc_butelek;
cin >> n >> k;
ilosc_butelek = n * (n + 1);
ilosc_butelek /= 2;
int t1;
for (int i = 0; i < n; i++) {
for (int j = 0; j < i + 1; j++) {
cin >> t1;
piramida[i].push_back(t1);
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < i + 1; j++) {
if (i == 0) {
butle[i].push_back(1);
}
else {
if (j == 0) {
butle[i].push_back(butle[i - 1][j] + 1);
}
else if (j == i) {
butle[i].push_back(butle[i - 1][j - 1] + 1);
}
else {
butle[i].push_back(butle[i - 1][j - 1] + butle[i - 1][j] + 1 - butle[i - 2][j - 1]);
}
}
}
}
int max_rok = 4000;
for (int i = 0; i < n; i++) {
for (int j = 0; j < i + 1; j++) {
if (piramida[i][j] < max_rok) {
if (butle[i][j] <= k) {
max_rok = piramida[i][j];
}
}
}
}
cout << max_rok;
//system("sleep");
return 0;
}