#include<bits/stdc++.h>
using namespace std;
const int maxn=100;
int cost[maxn][maxn];
int main()
{
int a,b;
cin>>a>>b;///输入行数列数
///输入地图
for(int i=0; i<a; i++)
for(int j=0; j<b; j++)
cin>>cost[i][j];
int m,n;
cin>>m>>n;///输入目的地,起点默认为(0,0)
for(int i=0; i<a; i++)
{
for(int j=0; j<b; j++)
{
if(j==0 && i>0) cost[i][j]+=cost[i-1][j];///处理边界
else if(j>0 && i==0) cost[i][j]+=cost[i][j-1];
else cost[i][j]+=min(cost[i-1][j],min(cost[i-1][j-1],cost[i][j-1]));
}
}
cout<<cost[m][n]<<endl;
return 0;
}