#include <bits/stdc++.h>
using namespace std;
int dir[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
int main() {
  int n, m;
  cin >> n >> m;
  int r, c;
  cin >> r >> c;
  int x, y;
  cin >> x >> y;
  vector<vector<char> > v(n, vector<char>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cin >> v[i][j];
  }
  deque<vector<int> > q;
  vector<int> node(4);
  vector<int> temp(4);
  node[0] = r;
  node[1] = c;
  node[2] = 0;
  node[3] = 0;
  q.push_back(node);
  vector<vector<int> > visit(n, vector<int>(m));
  int ans = 0;
  while (!q.empty()) {
    node = q.front();
    q.pop_front();
    visit[node[0] - 1][node[1] - 1] = true;
    ans++;
    for (int i = 0; i < 2; i++) {
      int r1 = node[0] + dir[i][0];
      int c1 = node[1] + dir[i][1];
      if (((r1 >= 1) && (r1 <= n)) && ((c1 >= 1) && (c1 <= m))) {
        if ((!visit[r1 - 1][c1 - 1]) && (v[r1 - 1][c1 - 1] == '.')) {
          temp[0] = r1, temp[1] = c1, temp[2] = node[2], temp[3] = node[3];
          q.push_front(temp);
          visit[r1 - 1][c1 - 1] = true;
        }
      }
    }
    for (int i = 2; i < 4; i++) {
      int r1 = node[0] + dir[i][0];
      int c1 = node[1] + dir[i][1];
      if (((r1 >= 1) && (r1 <= n)) && ((c1 >= 1) && (c1 <= m))) {
        if ((!visit[r1 - 1][c1 - 1]) && (v[r1 - 1][c1 - 1] == '.')) {
          temp[0] = r1, temp[1] = c1, temp[2] = node[2] + (i == 2),
          temp[3] = node[3] + (i == 3);
          if ((temp[2] <= x) && (temp[3] <= y)) q.push_back(temp);
          visit[r1 - 1][c1 - 1] = true;
        }
      }
    }
  }
  cout << ans;
}
