#include <bits/stdc++.h>
using namespace std;
int n, m, r, c, pp, qq, vis[2000 + 5][2000 + 5], ans;
char a[2000 + 5][2000 + 5];
struct S {
  int x, y, le, ri;
};
void bfs() {
  deque<S> q;
  q.push_front(S{r, c, pp, qq});
  vis[r][c] = 1;
  int nx, ny;
  while (!q.empty()) {
    S 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(S{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(S{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(S{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(S{nx, ny, u.le, u.ri - 1});
    }
  }
}
int main() {
  scanf("%d%d%d%d%d%d", &n, &m, &r, &c, &pp, &qq);
  for (int i = 1; i <= n; ++i) scanf("%s", a[i] + 1);
  bfs();
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) ans += vis[i][j];
  cout << ans << endl;
  return 0;
}
