#include <bits/stdc++.h>
using namespace std;
int dir[4][2] = {-1, 0, 1, 0, 0, -1, 0, 1};
int n, m, ans = 0;
char maze[2010][2010];
bool vis[2010][2010];
struct Point {
  int x, y, l, r;
  Point(int _x, int _y, int _l, int _r) : x(_x), y(_y), l(_l), r(_r) {}
};
bool in(int x, int y) { return 0 <= x && x < n && 0 <= y && y < m; }
void bfs(int sx, int sy, int left, int right) {
  deque<Point> q;
  q.push_back(Point(sx, sy, left, right));
  while (!q.empty()) {
    int x = q.front().x, y = q.front().y, l = q.front().l, r = q.front().r;
    q.pop_front();
    if (vis[x][y]) continue;
    vis[x][y] = 1;
    ans++;
    for (int i = 0; i < 4; i++) {
      int tx = x + dir[i][0];
      int ty = y + dir[i][1];
      if (in(tx, ty) && maze[tx][ty] != '*' && !vis[tx][ty]) {
        if (ty - y == 1 && r)
          q.push_back(Point(tx, ty, l, r - 1));
        else if (ty - y == -1 && l)
          q.push_back(Point(tx, ty, l - 1, r));
        else if (tx - x == 1 || tx - x == -1)
          q.push_front(Point(tx, ty, l, r));
      }
    }
  }
  return;
}
int main() {
  cin >> n >> m;
  int r, c, x, y;
  cin >> r >> c >> x >> y;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> maze[i][j];
    }
  }
  bfs(r - 1, c - 1, x, y);
  cout << ans << endl;
  return 0;
}
