#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
struct node {
  int x, y, l, r;
} t;
deque<node> q;
char s[N][N];
bool vis[N][N];
int go[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
int main() {
  int n, m, r, c, x, y;
  scanf("%d %d", &n, &m);
  scanf("%d %d", &x, &y);
  scanf("%d %d", &r, &c);
  for (int i = 1; i <= n; i++) {
    scanf("%s", s[i] + 1);
  }
  vis[x][y] = 1;
  q.push_back({x, y, r, c});
  while (!q.empty()) {
    t = q.front();
    q.pop_front();
    for (int i = 0; i < 4; i++) {
      int dx = t.x + go[i][0];
      int dy = t.y + go[i][1];
      if (dx < 1 || dy < 1 || dx > n || dy > m || vis[dx][dy] ||
          s[dx][dy] == '*')
        continue;
      if (dy == t.y) {
        vis[dx][dy] = 1;
        q.push_front({dx, dy, t.l, t.r});
      } else {
        if (dy < t.y && t.l > 0)
          vis[dx][dy] = 1, q.push_back({dx, dy, t.l - 1, t.r});
        if (dy > t.y && t.r > 0)
          vis[dx][dy] = 1, q.push_back({dx, dy, t.l, t.r - 1});
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      ans += vis[i][j];
    }
  }
  cout << ans;
}
