#include <bits/stdc++.h>
using namespace std;
typedef struct {
  int x, y;
} Pair;
inline void getint(int &num) {
  register int ch, neg = 0;
  while (!isdigit(ch = getchar()))
    if (ch == '-') neg = 1;
  num = ch & 15;
  while (isdigit(ch = getchar())) num = num * 10 + (ch & 15);
  if (neg) num = -num;
}
int n, m, r, c, lmv, rmv, lmov[2002][2002], rmov[2002][2002], ans, fr, re;
char mp[2002][2002];
bool vis[2002][2002];
Pair q[4000002], u;
inline void pushColumn(int r, int c, int lmv, int rmv) {
  for (register int i = r; i && mp[i][c] == '.'; i--) {
    vis[i][c] = 1, ans++, q[re++] = (Pair){i, c};
    lmov[i][c] = lmv, rmov[i][c] = rmv;
  }
  for (register int i = r + 1; i <= n && mp[i][c] == '.'; i++) {
    vis[i][c] = 1, ans++, q[re++] = (Pair){i, c};
    lmov[i][c] = lmv, rmov[i][c] = rmv;
  }
}
int main() {
  getint(n), getint(m), getint(r), getint(c), getint(lmv), getint(rmv);
  for (register int i = 1; i <= n; i++) scanf("%s", mp[i] + 1);
  fr = re = 0, pushColumn(r, c, lmv, rmv);
  while (fr != re) {
    u = q[fr++];
    if (mp[u.x][u.y - 1] == '.' && !vis[u.x][u.y - 1] && lmov[u.x][u.y])
      pushColumn(u.x, u.y - 1, lmov[u.x][u.y] - 1, rmov[u.x][u.y]);
    if (mp[u.x][u.y + 1] == '.' && !vis[u.x][u.y + 1] && rmov[u.x][u.y])
      pushColumn(u.x, u.y + 1, lmov[u.x][u.y], rmov[u.x][u.y] - 1);
  }
  printf("%d\n", ans);
  return 0;
}
