#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2005;
struct point {
  int x, y;
  int l, r;
};
bool vis[MAXN][MAXN];
int g[MAXN][MAXN];
int n, m;
point s;
void init() {
  cin >> n >> m;
  cin >> s.x >> s.y;
  cin >> s.l >> s.r;
}
int dx[4] = {0, 0, -1, 1};
int dy[4] = {-1, 1, 0, 0};
inline bool valid(const int& x, const int& y) {
  return x <= n && y <= m && x >= 1 && y >= 1;
}
void bfs() {
  deque<point> q;
  vis[s.x][s.y] = 1;
  q.push_back(s);
  while (!q.empty()) {
    point u = q.front();
    q.pop_front();
    int& x = u.x;
    int& y = u.y;
    int& l = u.l;
    int& r = u.r;
    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      if (!valid(nx, ny) || vis[nx][ny] || !g[nx][ny]) continue;
      if (i == 0 && l) {
        q.push_back((point){nx, ny, l - 1, r});
        vis[nx][ny] = 1;
      } else if (i == 1 && r) {
        q.push_back((point){nx, ny, l, r - 1});
        vis[nx][ny] = 1;
      } else if (i == 2 || i == 3) {
        q.push_front((point){nx, ny, l, r});
        vis[nx][ny] = 1;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (vis[i][j]) ans++;
  cout << ans << endl;
}
void work() {
  char ch;
  getchar();
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      ch = getchar();
      if (ch == '.')
        g[i][j] = 1;
      else
        g[i][j] = 0;
    }
    getchar();
  }
  bfs();
}
int main() {
  init();
  work();
  return 0;
}
