#include <bits/stdc++.h>
const int N = 1 << 24;
char map[N];
int dis[N], X, Y, x, y, L, R;
inline bool chk(int d, int s) { return s - d <= L && s + d <= R; }
int main() {
  memset(dis, 0x3f, sizeof dis);
  scanf("%d%d%d%d%d%d", &X, &Y, &x, &y, &L, &R);
  L <<= 1;
  R <<= 1;
  memset(map, '*', ++Y);
  for (int i = 1; i <= X; i++) {
    map[i * Y] = '*';
    scanf("%s", map + i * Y + 1);
  }
  memset(map + (X + 1) * Y, '*', Y + 1);
  std::deque<int> q;
  q.push_back(x * Y + y);
  dis[x * Y + y] = 0;
  int ans = 0;
  while (!q.empty()) {
    int a = q.front(), d = dis[a];
    q.pop_front();
    if (map[a] == '*') continue;
    if (!chk(a % Y - y, d)) continue;
    map[a] = '*';
    ans++;
    if (map[a - Y] != '*' && dis[a - Y] > d)
      dis[a - Y] = d, q.push_front(a - Y);
    if (map[a + Y] != '*' && dis[a + Y] > d)
      dis[a + Y] = d, q.push_front(a + Y);
    if (map[a - 1] != '*' && dis[a - 1] > d + 1)
      dis[a - 1] = d + 1, q.push_back(a - 1);
    if (map[a + 1] != '*' && dis[a + 1] > d + 1)
      dis[a + 1] = d + 1, q.push_back(a + 1);
  }
  printf("%d\n", ans);
  return 0;
}
