#include <bits/stdc++.h>
using namespace std;
const int maxn = 2100 + 100;
const int INF = 0x3f3f3f3f;
const long long mod = 1e9 + 7;
const double pi = acos(-1);
int dp[maxn][maxn][3];
int Map[maxn][maxn];
char f[maxn];
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};
int n, m;
struct node {
  int x, y;
  int l, r;
} st;
bool pan(int x, int y, int l, int r) {
  if (x >= 1 && x <= n && y >= 1 && y <= m && Map[x][y]) {
    if (dp[x][y][0] < l || dp[x][y][1] < r || dp[x][y][2] == 0) {
      dp[x][y][0] = l;
      dp[x][y][1] = r;
      dp[x][y][2] = 1;
      return 1;
    }
  }
  return 0;
}
void bfs() {
  queue<node> Q;
  Q.push(st);
  dp[st.x][st.y][0] = st.l;
  dp[st.x][st.y][1] = st.r;
  dp[st.x][st.y][2] = 1;
  while (!Q.empty()) {
    node u = Q.front();
    Q.pop();
    for (int i = 0; i < 4; i++) {
      int x = u.x + dx[i];
      int y = u.y + dy[i];
      int l = u.l;
      int r = u.r;
      if (i == 2) l--;
      if (i == 3) r--;
      if (l < 0 || r < 0) continue;
      if (pan(x, y, l, r)) {
        node v;
        v.x = x;
        v.y = y;
        v.l = l;
        v.r = r;
        Q.push(v);
      }
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  scanf("%d%d", &st.x, &st.y);
  scanf("%d%d", &st.l, &st.r);
  for (int i = 1; i <= n; i++) {
    scanf("%s", f + 1);
    for (int j = 1; j <= m; j++) {
      int w = 0;
      if (f[j] == '.') w = 1;
      Map[i][j] = w;
    }
  }
  bfs();
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (dp[i][j][2]) {
        ans++;
      }
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
