#include <bits/stdc++.h>

#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define FILL0(x) memset(x,0,sizeof(x))
#define FILL1(x) memset(x,-1,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
 
int w, h;

bool used[100][100];
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};

vector<string> s;

int dfs(int y, int x){
    int ans = 0;
    rep(i, 4){
        int ny = y + dy[i];
        int nx = x + dx[i];

        while(0<=ny && 0<=nx && ny<h &&nx<w && !used[ny][nx] && s[ny][nx]=='.'){
            used[ny][nx] = true;
            ans++;
            ny += dy[i];
            nx += dx[i];
        }
    }
    return ans;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    FILL0(used);

    int x, y;
    cin >> h >> w  >> y >> x;
    x--; y--;
    rep(i, h){
        string ss;
        cin >> ss;
        s.push_back(ss);
    }
    used[y][x] = true;
    cout << dfs(y, x)+1 << endl;


    return 0;

}

/*Bismillahir Rahmanir Rahim*/
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define PI acos(-1.0)
using namespace std;
int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,m,x,y,p,q;
    cin>>n>>m>>x>>y;
    char a[109][109];
    ll i,j,cnt=0;
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++) cin>>a[i][j];
    }
    x--;y--;
    p=x-1,q=y;
    while(a[p][q]!='#'&&p>=0) {cnt++;p--;}
    p=x+1,q=y;
    while(a[p][q]!='#'&&p<n) {cnt++;p++;}
    p=x,q=y-1;
    while(a[p][q]!='#'&&q>=0) {cnt++;q--;}
    p=x,q=y+1;
    while(a[p][q]!='#'&&q<m) {cnt++;q++;}
    cnt++;
    cout<<cnt<<endl;
}
