#include <bits/stdc++.h>
using namespace std;
bool vis[2005][2005];
char a[2005][2005];
int n, m, r, c, x, y, ans;
string str;
struct node {
  int x, y, le, ri;
};
void bfs() {
  deque<node> q;
  q.push_front(node{r, c, x, y});
  vis[r][c] = 1;
  int nx, ny;
  while (!q.empty()) {
    node u = q.front();
    q.pop_front();
    nx = u.x + 1, ny = u.y;
    if (nx <= n && !vis[nx][ny] && a[nx][ny] == '.') {
      vis[nx][ny] = 1;
      q.push_front(node{nx, ny, u.le, u.ri});
    }
    nx = u.x - 1, ny = u.y;
    if (nx >= 1 && !vis[nx][ny] && a[nx][ny] == '.') {
      vis[nx][ny] = 1;
      q.push_front(node{nx, ny, u.le, u.ri});
    }
    nx = u.x, ny = u.y - 1;
    if (ny >= 1 && !vis[nx][ny] && u.le >= 1 && a[nx][ny] == '.') {
      vis[nx][ny] = 1;
      q.push_back(node{nx, ny, u.le - 1, u.ri});
    }
    nx = u.x, ny = u.y + 1;
    if (ny <= m && !vis[nx][ny] && u.ri >= 1 && a[nx][ny] == '.') {
      vis[nx][ny] = 1;
      q.push_back(node{nx, ny, u.le, u.ri - 1});
    }
  }
}
int main() {
  cin >> n >> m >> r >> c >> x >> y;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  }
  bfs();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) ans += vis[i][j];
  }
  cout << ans;
  return 0;
}
