#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 10;
int n, m, sx, sy, l, r;
int dx[] = {-1, 0, 0, 1};
int dy[] = {0, 1, -1, 0};
struct Node {
  int x, y, sl, sr;
  Node() {}
  Node(int a, int b, int c, int d) : x(a), y(b), sl(c), sr(d) {}
};
char mp[maxn][maxn];
bool vis[maxn][maxn];
deque<Node> qu;
int main() {
  int i, j;
  scanf("%d%d", &n, &m);
  scanf("%d%d", &sx, &sy);
  scanf("%d%d", &l, &r);
  for (i = 1; i <= n; i++) {
    scanf("%s", mp[i] + 1);
  }
  int ans = 1;
  vis[sx][sy] = true;
  qu.push_front(Node(sx, sy, l, r));
  while (!qu.empty()) {
    Node no = qu.front();
    qu.pop_front();
    for (i = 0; i < 4; i++) {
      int xx = no.x + dx[i];
      int yy = no.y + dy[i];
      if (vis[xx][yy] || xx < 1 || xx > n || yy < 1 || yy > m ||
          mp[xx][yy] == '*')
        continue;
      if (i == 1) {
        if (no.sr >= 1) {
          vis[xx][yy] = true;
          ans++;
          qu.push_back(Node(xx, yy, no.sl, no.sr - 1));
        }
      } else if (i == 2) {
        if (no.sl >= 1) {
          vis[xx][yy] = true;
          ans++;
          qu.push_back(Node(xx, yy, no.sl - 1, no.sr));
        }
      } else {
        vis[xx][yy] = true;
        ans++;
        qu.push_front(Node(xx, yy, no.sl, no.sr));
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
