#include <cstdio>
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
int k, n;
int age[2004][2004], height[2004][2004];
int main(){
for(int i=0; i<2004; i++){
for(int j=0; j<2004; j++){
age[i][j]=0;
height[i][j]=0;
}
}
scanf("%d %d", &n, &k);
int max_age=55555;
for(int i=1; i<=n; i++){
for(int j=1; j<=i; j++){
scanf("%d", &age[i][j]);
height[i][j]=height[i-1][j-1] + height[i-1][j] + 1 - ((i>1)?height[i-2][j-1]:0);
if(height[i][j]<=k && age[i][j]<max_age) max_age=age[i][j];
}
}
printf("%d\n", max_age);
return 0;
}