#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define eb emplace_back
#define unused [[maybe_unused]]
#define tempT template<class T>
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl
#define ans_exit(x) { cout << x << endl; exit(0); }
#define ans_return(x) { cout << x << endl; return; }
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define r_rep(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define reps(i, n, m) for (ll i = (ll)(n); i < (ll)(m); i++)
#define r_reps(i, n, m) for (ll i = (ll)(m) - 1; i >= (ll)(n); i--)
#define _prarr(a) {for(auto _e:a){cerr << _e << " ";} cerr << endl;}
#define debugarr(a) {cerr << #a << ": "; _prarr(a);}
 
using ll   unused = long long;
using ld   unused = long double;
using vl   unused = vector<ll>;
using vvl  unused = vector<vl>;
using vvvl unused = vector<vvl>;
using lp   unused = pair<ll, ll>;
using lmap unused = map<int, int>;
 
unused constexpr ll MOD = 1e9 + 7;
unused constexpr ll INF = 1 << 29;
unused constexpr ll LINF = 1LL << 61;
unused constexpr int DX[8] = {0, 1, 0,-1, 1, 1,-1,-1};
unused constexpr int DY[8] = {1, 0,-1, 0, 1,-1, 1,-1};
unused inline bool bit(ll b, ll i) { return b & (1LL << i); }
unused inline ll ceiv(ll a, ll b) { return (a + b - 1) / b; }
unused inline ll mod(ll a, ll m = MOD) { return (a % m + m) % m; }
unused inline void modadd(ll &a, ll b, ll m = MOD) { a = mod(a + b, m); }
unused inline ll floordiv(ll a, ll b) { return a / b - (a < 0 && a % b); }
unused inline ll ceildiv(ll a, ll b) { return floordiv(a + b - 1, b); }
tempT unused bool chmin(T &a, T b) { if(a > b) {a = b; return 1;} return 0; }
tempT unused bool chmax(T &a, T b) { if(a < b) {a = b; return 1;} return 0; }

ll t;

ll f(ll x) {
    return (100 + t) * x / 100;
}

int main(){
    ll n; cin >> t >> n;
    ll losts = f(100) - 100;
    ll x = n / losts - !(n % losts);
    ll y = n - x * losts;

    vl a;
    reps(i, 100 * x, 100 * (x + 2)) {
        a.pb(f(i));
    }

    rep(i, 102) {
        if(a[i + 1] - a[i] == 1) continue;
        y--;
        if(!y) {
            cout << a[i] + 1 << endl;
        }
    }
}
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef pair<int,pii> pip;
const int MAXN = 505;
const int INF = 1000000007;
int A[MAXN][MAXN], B[MAXN][MAXN], min_dist[MAXN][MAXN];
set <pip> dijk;
void update_dijk(int nr, int nc, int nwt)
{
	if (nwt < min_dist[nr][nc])
	{
		dijk.erase(pip(min_dist[nr][nc], pii(nr, nc)));
		min_dist[nr][nc] = nwt;
		dijk.insert(pip(min_dist[nr][nc], pii(nr, nc)));
	}
}
int main(int argc, char const *argv[])
{
	int r, c;
	cin>>r>>c;
	for (int i = 0; i < r; ++i)
	{
		for (int j = 0; j < c - 1; ++j)
		{
			cin>>A[i][j];
		}
	}
	for (int i = 0; i < r - 1; ++i)
	{
		for (int j = 0; j < c; ++j)
		{
			cin>>B[i][j];
		}
	}
	for (int i = 0; i < r; ++i)
	{
		for (int j = 0; j < c; ++j)
		{
			min_dist[i][j] = INF;
		}
	}

	min_dist[0][0] = 0;
	dijk.insert(pip(min_dist[0][0], pii(0,0)));

	while (!dijk.empty())
	{
		pip top = *dijk.begin();
		dijk.erase(dijk.begin());

		int cwt = top.first, cr = top.second.first, cc = top.second.second;
		int nr, nc, nwt;

		nr = cr;
		nc = cc + 1;
		if (nc < c)
		{
			nwt = cwt + A[cr][cc];
			update_dijk(nr, nc, nwt);
		}

		nr = cr;
		nc = cc - 1;
		if (nc >= 0)
		{
			nwt = cwt + A[cr][cc - 1];
			update_dijk(nr, nc, nwt);
		}

		nr = cr + 1;
		nc = cc;
		if (nr < r)
		{
			nwt = cwt + B[cr][cc];
			update_dijk(nr, nc, nwt);
		}

		for (int i = 1; i <= cr; ++i)
		{
			nr = cr - i;
			nc = cc;
			nwt = cwt + (i + 1);
			update_dijk(nr, nc, nwt);
		}
	}
	// for (int i = 0; i < r; ++i)
	// {
	// 	for (int j = 0; j < c; ++j)
	// 	{
	// 		cout<<min_dist[i][j]<<" ";
	// 	}
	// 	cout<<"\n";
	// }
	cout<<min_dist[r - 1][c - 1]<<"\n";
	return 0;
}