#include <bits/stdc++.h>
using namespace std;
int n, m, rt, lt, si, sj;
char mat[2005][2005];
vector<vector<int> > vis;
int fy[] = {1, -1, 0, 0};
int fx[] = {0, 0, 1, -1};
bool valid(int i, int j) {
  if (i < 0 || i >= n || j < 0 || j >= m) return false;
  return true;
}
void BFS() {
  struct node {
    int i, j, rt, lt;
  };
  deque<node> q;
  q.push_back({si, sj, rt, lt});
  while (!q.empty()) {
    node nd = q.front();
    q.pop_front();
    vis[nd.i][nd.j] = 1;
    for (int i = 0; i < 4; i++) {
      int y = nd.i + fy[i];
      int x = nd.j + fx[i];
      if (valid(y, x) && mat[y][x] == '.' && vis[y][x] == 0) {
        int tr = nd.rt, tl = nd.lt;
        if (i == 2 && tr > 0) {
          vis[y][x] = 1;
          q.push_back({y, x, --tr, tl});
        } else if (i == 3 && tl > 0) {
          vis[y][x] = 1;
          q.push_back({y, x, tr, --tl});
        } else if (i == 0 || i == 1) {
          vis[y][x] = 1;
          q.push_front({y, x, tr, tl});
        }
      }
    }
  }
}
int main() {
  scanf("%d %d", &n, &m);
  scanf("%d %d", &si, &sj);
  --si, --sj;
  scanf("%d %d", &lt, &rt);
  vis.assign(n, vector<int>(m, 0));
  for (int i = 0; i < n; i++) cin >> mat[i];
  BFS();
  int cnt = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (vis[i][j]) cnt++;
  cout << cnt << endl;
  return 0;
}
