#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define Rep(i,n) for(int i=0;i<=(int)n;i++)
const ll mod = 1e9+7 ;
const ll INF = 1e18 ;
ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}


int main(){
    ll t, n;
    cin >> t >> n;
    vector<bool> a(100 + t,true);
    rep(i,100) a.at(i * (100 + t) /100) = false;
    vector<int> b;
    rep(i,100 + t) if(a.at(i)) b.push_back(i);
    ll count = n % b.size() - 1;
    if(count == -1) {
        cout << (n / b.size() - 1) * (100 + t) + b.at(b.size() - 1)<< endl;
        return 0;
    }
    cout << (n / b.size()) * (100 + t) + b.at(count) << endl;
}
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vll vector<long long>
#define pll pair<long long, long long>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1e18
 

typedef long long ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
  ll n,k;
  cin>>n>>k;
  vector<vll> a(n,vll(n));
  ll i,j;
  for(i=0;i<n;i++)
  {
    for(j=0;j<n;j++)
    {
      cin>>a[i][j];
    }
  }
  
  function<bool(ll)> good = [&](ll x)
  {
    vector<vll> dp(n,vll(n,0));
    for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
      {
        if(a[i][j] <= x)dp[i][j] = 1;
      }
    }
    for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
      {
        if(i>0&&j>0)dp[i][j]-=dp[i-1][j-1];
        if(i>0)dp[i][j]+=dp[i-1][j];
        if(j>0)dp[i][j]+=dp[i][j-1];
      }
    }
    for(i=0;i+k-1<n;i++)
    {
      for(j=0;j+k-1<n;j++)
      {
        ll sx = i,sy = j;
        ll ex = i+k-1,ey = j+k-1;
        ll count = dp[ex][ey];
        if(sx > 0)count-=dp[sx-1][ey];
        if(sy > 0)count-=dp[ex][sy-1];
        if(sx > 0 && sy > 0)count+=dp[sx-1][sy-1];
        if(count >= (k*k+1)/2 )return true;
      }
    }
    return false;
  };

  ll l = 0,r = 1e10;
  ll fans = -1;
  while(l<=r)
  {
    ll mid = l+(r-l)/2;
    if(good(mid))
    {
      fans = mid;
      r = mid-1;
    }
    else{
      l = mid+1;
    }
  }
  cout<<fans<<"\n";
}
 


int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}