#include <bits/stdc++.h>
using namespace std;
int n, m, vis[2005][2005], ans, sx, sy, L, R;
int dir[4][2] = {{1, 0}, {-1, 0}, {0, -1}, {0, 1}};
char mp[2005][2005];
struct node {
  int x, y, l, r;
};
bool check(node x) {
  if (x.x <= 0 || x.y <= 0 || x.x > n || x.y > m || vis[x.x][x.y] ||
      mp[x.x][x.y] == '*')
    return false;
  return true;
}
void BFS() {
  deque<node> que;
  vis[sx][sy] = 1;
  ans++;
  node s;
  s.x = sx;
  s.y = sy;
  s.l = L;
  s.r = R;
  que.push_back(s);
  while (!que.empty()) {
    node now = que.front();
    que.pop_front();
    node next;
    for (int i = 0; i < 4; i++) {
      next.x = now.x + dir[i][0];
      next.y = now.y + dir[i][1];
      if (check(next)) {
        if (i < 2) {
          next.l = now.l;
          next.r = now.r;
          que.push_front(next);
          vis[next.x][next.y] = 1;
          ans++;
        }
        if (i == 2 && now.l >= 1) {
          next.l = now.l - 1;
          next.r = now.r;
          que.push_back(next);
          vis[next.x][next.y] = 1;
          ans++;
        }
        if (i == 3 && now.r >= 1) {
          next.l = now.l;
          next.r = now.r - 1;
          que.push_back(next);
          vis[next.x][next.y] = 1;
          ans++;
        }
      }
    }
  }
}
int main() {
  scanf("%d%d%d%d%d%d", &n, &m, &sx, &sy, &L, &R);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> mp[i][j];
  BFS();
  cout << ans << endl;
  return 0;
}
