#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
const int INF = 1000000009;
const LL LINF = 1000000000000000009LL;
#define FOR(i, b, e) for (int i = b; i <= e; ++i)
#define FORD(i, b, e) for (int i = b; i >= e; --i)
#define REP(i, n) FOR (i, 0, n - 1)
#define REV(i, n) FORD (i, n - 1, 0)
#define PB push_back
#define PP pop_back
#define MP make_pair
#define MT make_tuple
#define ST first
#define ND second
#define SZ(c) (int)(c).size()
#define ALL(c) (c).begin(), (c).end()
#define UNIQ(c) (c).erase(unique(ALL(c)), (c).end());
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/hash_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; /*find_by_order() order_of_key()*/
template <typename T, typename S>
ostream &operator<<(ostream &out, const pair<T, S> &v)
{
return (out << "(" << v.ST << ", " << v.ND << ")");
}
#define DEBUG(s) s
#ifdef local_comp
#define PRINT(V) cout << "#" << #V << ": " << V << endl;
#else
#define PRINT(v)
#endif
const int N = 2005;
int tab[N][N];
int dp[N][N];
int n, k;
int main()
{
#ifndef local_comp
ios::sync_with_stdio(0);
cin.tie(0);
#endif
cin >> n >> k;
FOR (i, 1, n)
FOR (j, 1, i)
cin >> tab[i][j];
dp[1][1] = 1;
FOR (i, 2, n)
{
FOR (j, 1, i)
{
dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j] - dp[i - 2][j - 1] + 1;
}
}
// FOR (i, 1, n)
// {
// FOR (j, 1, i)
// {
// cout << dp[i][j] << " ";
// }
// cout << "\n";
// }
int res = 2019;
FOR (i, 1, n)
FOR (j, 1, i)
if (dp[i][j] <= k)
res = min(res, tab[i][j]);
cout << res << "\n";
return 0;
}