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