/**
 * Author: Daniel
 * Created Time: 2021-03-27 20:02:48
**/

// time-limit: 2000
#include <bits/stdc++.h>

using namespace std;

#define F first 
#define S second
#define ER erase
#define IS insert
#define PI acos(-1)
#define PB pop_back
#define MP make_pair
#define MT make_tuple
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define lowbit(x) (x & -x)
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
#define SOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<fixed<<setprecision(10)

typedef long long LL;
typedef vector<LL> VL;
typedef vector<int> VI;
typedef pair<LL, LL> PLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef unsigned long long ULL;
typedef pair<double, double> PDD;
typedef vector<pair<LL, LL> > VPLL;
typedef vector<pair<int, int> > VPII;

template <typename A> using VE = vector<A>;
template <typename A> using USET = unordered_set<A>;
template <typename A> using HEAP = priority_queue<A>;
template <typename A, typename B> using PA = pair<A, B>;
template <typename A, typename B> using UMAP = unordered_map<A, B>;
template <typename A> using RHEAP = priority_queue<A, vector<A>, greater<A> >;

template <typename A> A MAX(const A &a) { return a; }
template <typename A> A MIN(const A &a) { return a; }
template <typename A> A MAX(const A *a, const A *b) { assert(b - a > 0); return *max_element(a, b); }
template <typename A> A MIN(const A *a, const A *b) { assert(b - a > 0); return *min_element(a, b); }
template <typename A, typename... B> A MAX(const A &a, const B&... b) { return max(a, MAX(b...)); }
template <typename A, typename... B> A MIN(const A &a, const B&... b) { return min(a, MIN(b...)); }
template <typename A, typename B = typename std::iterator_traits<A>::value_type> B MAX(A a, A b) { assert(b - a > 0); return *max_element(a, b); }
template <typename A, typename B = typename std::iterator_traits<A>::value_type> B MIN(A a, A b) { assert(b - a > 0); return *min_element(a, b); }

mt19937 rng((unsigned int)chrono::steady_clock::now().time_since_epoch().count());

///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////

// check the limitation!!!
const int N = 100010, M = 1010;



// read the question carefully!!!
int main()
{
    SOS;

    int n, m, x, y;
    cin >> n >> m >> x >> y;
    x -- , y -- ;
    VS g(n);
    for (auto &s : g) cin >> s;
    int res = 1;
    for (int j = y + 1; j < m; j ++ )
        if (g[x][j] == '.') res ++ ;
        else break;
    for (int j = y - 1; j >= 0; j -- )
        if (g[x][j] == '.') res ++ ;
        else break;
    for (int i = x - 1; i >= 0; i -- )
        if (g[i][y] == '.') res ++ ;
        else break;
    for (int i = x + 1; i < n; i ++ )
        if (g[i][y] == '.') res ++ ;
        else break;
    cout << res << '\n';
    return 0;
}

// GOOD LUCK!!!

#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
using namespace std;
using p = pair<int, int>;
vector<p> d = {p(-1,0), p(1,0), p(0,-1), p(0,1)};

int main() {
  int h, w, x, y;
  cin >> h >> w >> x >> y;
  x--;
  y--;

  vector<vector<char>> v(h, vector<char>(w));

  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      cin >> v[i][j];
    }
  }

  int ans = 0;

  for (auto coord: d) {
    bool b = true;
    int s, t;
    int t_x = x, t_y = y;
    tie(s, t) = coord;
    while (b) {
      t_x += s;
      t_y += t;
      if ((t_x>=h) || (t_x<0) || (t_y>=w) || (t_y<0) || (v[t_x][t_y]=='#')) {
        b = false;
      } else {
        ans += 1;
      }
    }
  }

  if (v[x][y]=='.') {
    cout << ans+1 << endl;
  } else {
    cout << ans << endl;
  }
}
