// #define _GLIBCXX_DEBUG
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
// #include <atcoder>
// using namespace atcoder;
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    random_device seed;
    mt19937 engine(seed());
    int query = 1000;
    vector<ll> sp;
    while (query--) {
        ll si, sj, ti, tj;
        cin >> si >> sj >> ti >> tj;
        ll x = abs(si - ti);
        ll y = abs(sj - tj);
        string path;
        if (si < ti) {
            for (int i = 0; i < x; i++) {
                path.push_back('D');
            }
        } else {
            for (int i = 0; i < x; i++) {
                path.push_back('U');
            }
        }
        if (sj < tj) {
            for (int i = 0; i < y; i++) {
                path.push_back('R');
            }
        } else {
            for (int i = 0; i < y; i++) {
                path.push_back('L');
            }
        }
        cout << path << endl;
        ll shortest_path;
        cin >> shortest_path;
        sp.emplace_back(shortest_path);
    }
    return 0;
}
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
int a[107][107];
int n,m,x,y,disx[4]={0,1,0,-1},disy[4]={1,0,-1,0};
int main(){
    scanf("%d%d%d%d",&n,&m,&x,&y);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            char t;
            scanf(" %c",&t);
            a[i][j]=(t=='#');
        }
    }
    int ans=0;
    for (int i = 0; i < 4; ++i) {
        int nx=x+disx[i],ny=y+disy[i];
        while(!a[nx][ny]){
            if(nx<1 || ny<1 || nx>n || ny>m) break;
            ans++;
            nx+=disx[i];
            ny+=disy[i];
        }
    }
    printf("%d",ans+1);
    return 0;
}