#include <bits/stdc++.h>
using namespace std;
const int Inf = 1e9;
inline int read() {
  int s = 0, m = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') m = 1;
    ch = getchar();
  }
  while (isdigit(ch)) s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
  return m ? -s : s;
}
int n, m, sx, sy, Le, Ri, Ans;
bool G[2050][2050];
bool vis[2050][2050];
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
struct AT {
  int le, ri;
} ljl[2050][2050];
struct NODE {
  int x, y, le, ri;
};
queue<NODE> Q;
inline void Bfs() {
  while (!Q.empty()) Q.pop();
  Q.push((NODE){sx, sy, Le, Ri});
  ljl[sx][sy] = (AT){Le, Ri}, vis[sx][sy] = 1;
  while (!Q.empty()) {
    register NODE tmp = Q.front();
    Q.pop();
    for (register int i = 0, nx, ny, nl, nr; i < 4; ++i) {
      nx = tmp.x + dx[i], ny = tmp.y + dy[i];
      nl = tmp.le, nr = tmp.ri;
      if (i == 0) --nr;
      if (i == 1) --nl;
      if (nl < 0 || nr < 0 || !G[nx][ny]) continue;
      if (nx < 1 || nx > n || ny < 1 || ny > m) continue;
      if (nl <= ljl[nx][ny].le && nr <= ljl[nx][ny].ri && vis[nx][ny]) continue;
      ljl[nx][ny] = (AT){nl, nr};
      Q.push((NODE){nx, ny, nl, nr});
      if (!vis[nx][ny]) vis[nx][ny] = 1, ++Ans;
    }
  }
}
int main() {
  n = read(), m = read();
  sx = read(), sy = read(), Le = read(), Ri = read();
  char gi;
  for (register int i = 1; i <= n; ++i)
    for (register int j = 1; j <= m; ++j) {
      cin >> gi;
      if (gi == '.')
        G[i][j] = true;
      else
        G[i][j] = false;
    }
  Bfs();
  printf("%d\n", Ans + 1);
  return 0;
}
