#include <bits/stdc++.h>
using namespace std;
bool mat[2005][2005];
int dpa[2005][2005];
int dpb[2005][2005];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, sx, sy, limx, limy;
  cin >> n >> m >> sx >> sy >> limx >> limy;
  memset(dpa, 255, sizeof(dpa));
  memset(dpb, 255, sizeof(dpb));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      mat[i][j] = (c == '.');
    }
  }
  list<pair<pair<int, int>, int> > q;
  q.push_back({{sx, sy}, 0});
  dpa[sx][sy] = 0;
  dpb[sx][sy] = 0;
  while (!q.empty()) {
    int x = q.front().first.first, y = q.front().first.second;
    int val = q.front().second;
    q.pop_front();
    if (val > dpa[x][y]) continue;
    if (mat[x - 1][y] && (dpa[x - 1][y] == -1 || val < dpa[x - 1][y])) {
      dpa[x - 1][y] = dpa[x][y];
      dpb[x - 1][y] = dpb[x][y];
      q.push_front({{x - 1, y}, dpa[x][y]});
    }
    if (mat[x + 1][y] && (dpa[x + 1][y] == -1 || val < dpa[x + 1][y])) {
      dpa[x + 1][y] = dpa[x][y];
      dpb[x + 1][y] = dpb[x][y];
      q.push_front({{x + 1, y}, dpa[x][y]});
    }
    if (mat[x][y - 1] && (dpa[x][y - 1] == -1 || val + 1 < dpa[x][y - 1])) {
      dpa[x][y - 1] = dpa[x][y] + 1;
      dpb[x][y - 1] = dpb[x][y];
      q.push_back({{x, y - 1}, dpa[x][y] + 1});
    }
    if (mat[x][y + 1] && (dpa[x][y + 1] == -1 || val < dpa[x][y + 1])) {
      dpa[x][y + 1] = dpa[x][y];
      dpb[x][y + 1] = dpb[x][y] + 1;
      q.push_front({{x, y + 1}, dpa[x][y]});
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (dpa[i][j] != -1 && dpa[i][j] <= limx && dpb[i][j] <= limy) {
        ans++;
      }
    }
  }
  cout << ans;
}
