#include <bits/stdc++.h>
using namespace std;
char mp[2005][2005];
int n, m, r, c, L, R, ans, vis[2005][2005];
struct node {
  int x, y, l, r;
  node();
  node(int x, int y, int l, int r) : x(x), y(y), l(l), r(r) {}
  bool operator<(const node &p) const { return l + r > p.l + p.r; }
};
priority_queue<node> q;
int main() {
  cin >> n >> m >> r >> c >> L >> R;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> mp[i][j];
  q.push(node(r, c, 0, 0));
  vis[r][c] = 1;
  while (!q.empty()) {
    node cur = q.top();
    q.pop();
    int x = cur.x, y = cur.y, l = cur.l, r = cur.r;
    if (x != 1 && mp[x - 1][y] != '*' && vis[x - 1][y] == 0) {
      vis[x - 1][y]++;
      q.push(node(x - 1, y, l, r));
    }
    if (x != n && mp[x + 1][y] != '*' && vis[x + 1][y] == 0) {
      vis[x + 1][y]++;
      q.push(node(x + 1, y, l, r));
    }
    if (y != 1 && mp[x][y - 1] != '*' && vis[x][y - 1] == 0 && l < L) {
      vis[x][y - 1]++;
      q.push(node(x, y - 1, l + 1, r));
    }
    if (y != m && mp[x][y + 1] != '*' && vis[x][y + 1] == 0 && r < R) {
      vis[x][y + 1]++;
      q.push(node(x, y + 1, l, r + 1));
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++)
      if (vis[i][j]) {
        ans++;
      }
  }
  printf("%d\n", ans);
  return 0;
}
