#include <bits/stdc++.h>
using namespace std;
int di[] = {-1, 1, 0, 0};
int dj[] = {0, 0, -1, 1};
long long lftc = 2000 * 2000 + 1;
long long rgtc = lftc * lftc + 1;
long long cost[] = {0, 0, lftc, rgtc};
char str[2005];
int n, m;
void dijk(int sr, int sc, vector<vector<long long> >& mat,
          const vector<string>& mp) {
  deque<pair<long long, pair<int, int> > > q;
  q.push_back(make_pair(0, make_pair(sr, sc)));
  while (q.size()) {
    pair<long long, pair<int, int> > cur = q.front();
    int r = cur.second.first;
    int c = cur.second.second;
    q.pop_front();
    for (int k = 0; k < 4; k++) {
      int rr = r + di[k];
      int cc = c + dj[k];
      long long cs = cost[k];
      if (rr >= 0 && cc >= 0 && rr < n && cc < m && mp[rr][cc] == '.' &&
          cs + cur.first < mat[rr][cc]) {
        mat[rr][cc] = cs + cur.first;
        if (cs)
          q.push_back(make_pair(mat[rr][cc], make_pair(rr, cc)));
        else
          q.push_front(make_pair(mat[rr][cc], make_pair(rr, cc)));
      }
    }
  }
}
int main() {
  int r, c;
  int lr, rr;
  scanf("%d%d", &n, &m);
  scanf("%d%d", &r, &c);
  scanf("%d%d", &lr, &rr);
  vector<string> mp(n);
  vector<vector<long long> > mat(n, vector<long long>(m, lftc * rgtc + 1));
  r--, c--;
  mat[r][c] = 0;
  for (int i = 0; i < n; i++) {
    scanf("%s", str);
    mp[i] = str;
  }
  dijk(r, c, mat, mp);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      long long val = mat[i][j];
      long long rcnt = val / rgtc;
      val %= rgtc;
      long long lcnt = val / lftc;
      if (mp[i][j] == '.' && lcnt <= lr && rcnt <= rr) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
