#include <bits/stdc++.h>
using namespace std;
static const int mx = 2e6 + 5;
static const int mod = 1e9 + 7;
long long int n, m, k, cnt = 0, x, y, r, c;
int fx[4] = {-1, +1, +0, +0};
int fy[4] = {+0, +0, -1, +1};
char a[2005][2005];
long long int vis[2005][2005];
long long int dis1[2005][2003];
long long int dis2[2003][3004];
void bfs1() {
  deque<pair<long long int, long long int> > dq;
  dq.push_back({r, c});
  dis1[r][c] = 0;
  while (!dq.empty()) {
    long long int p = dq.front().first;
    long long int q = dq.front().second;
    dq.pop_front();
    for (int i = 0; i < 4; i++) {
      long long int xx = p + fx[i];
      long long int yy = q + fy[i];
      if (xx >= 1 && xx <= n && yy >= 1 && yy <= m && a[xx][yy] == '.') {
        int ok = 0;
        if (i == 2) ok = 1;
        if (dis1[xx][yy] > dis1[p][q] + ok) {
          dis1[xx][yy] = dis1[p][q] + ok;
          if (i == 2)
            dq.push_back({xx, yy});
          else
            dq.push_front({xx, yy});
        }
      }
    }
  }
}
void bfs2() {
  deque<pair<long long int, long long int> > dq;
  dq.push_back({r, c});
  dis2[r][c] = 0;
  while (!dq.empty()) {
    long long int p = dq.front().first;
    long long int q = dq.front().second;
    dq.pop_front();
    for (int i = 0; i < 4; i++) {
      long long int xx = p + fx[i];
      long long int yy = q + fy[i];
      if (xx >= 1 && xx <= n && yy >= 1 && yy <= m && a[xx][yy] == '.') {
        int ok = 0;
        if (i == 3) ok = 1;
        if (dis2[xx][yy] > dis2[p][q] + ok) {
          dis2[xx][yy] = dis2[p][q] + ok;
          if (i == 3)
            dq.push_back({xx, yy});
          else
            dq.push_front({xx, yy});
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  long long int tot = 0;
  while (t--) {
    cin >> n >> m;
    cin >> r >> c;
    cin >> x >> y;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        cin >> a[i][j];
        dis1[i][j] = 1e15;
        dis2[i][j] = 1e15;
      }
    }
    bfs1();
    bfs2();
    long long int ans = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (dis1[i][j] <= x && dis2[i][j] <= y) {
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
}
