#include <iostream>
#include <cmath>
using namespace std;

int main()
{
    int h, w, x, y;
    cin >> h >> w >> x >> y;
    char s[h][w];
    for(int i=0; i<h; i++)
        for(int j=0; j<w; j++)
            cin>>s[i][j];
    x--;
    y--;
    int ans=0;
    for(int i=y+1; i<w; i++)
    {
        if(s[x][i]=='#')
            break;
        else
        {
            if(s[x][i] == '.')
                ans++;
        }
    }
    for(int i=y-1; i>=0; i--)
    {
        if(s[x][i]=='#')
            break;
        else
        {
            if(s[x][i] == '.')
                ans++;
        }
    }
     for(int i=x+1; i<h; i++)
    {
        if(s[i][y]=='#')
            break;
        else
        {
            if(s[i][y] == '.')
                ans++;
        }
    }
     for(int i=x-1; i>=0; i--)
    {
        if(s[i][y]=='#')
            break;
        else
        {
            if(s[i][y] == '.')
                ans++;
        }
    }
    cout << ans+1 << "\n";
}

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX5 100005
#define MAX6 1000006
#define MAX7 10000007
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define sfs(a) scanf("%s", a)
#define sline(a) scanf("%[^\n]%*c", a);
#define pf(a) printf("%d\n", a)
#define pfl(a) printf("%lld\n", a)
#define pfs(a) printf("%s\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mod 1000000007
#define Mod 998244353
#define PI acos(-1.0)
#define eps 1e-9
#define mem(a, b) memset(a, b, sizeof(a))
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

const int N = MAX5;

int main()
{
    //#ifndef ONLINE_JUDGE
    //    freopen("in.txt","r",stdin);
    //    freopen("out.txt","w",stdout);
    //#endif

    FASTIO;
    int n, m;
    cin>>n>>m;
    ll a[n][m];
    ll mn = inf;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            cin>>a[i][j];
            mn = min(mn, a[i][j]);
        }
    }
    ll ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            ans += max(0LL, a[i][j]-mn);
        }
    }
    cout<<ans<<endl;
    
    return 0;
}
