#include <bits/stdc++.h>
using namespace std;
int n, m;
int ans = 0;
long long vis[2100][2100];
struct Node {
  int sx, sy, x, y;
};
int main() {
  cin >> n >> m;
  int sx, sy;
  cin >> sx >> sy;
  int x, y;
  cin >> x >> y;
  deque<Node> q;
  vector<string> grid;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    grid.push_back(s);
  }
  q.push_front(Node{sx - 1, sy - 1, x, y});
  while (!q.empty()) {
    Node temp = q.front();
    q.pop_front();
    sx = temp.sx;
    sy = temp.sy;
    if (vis[sx][sy])
      continue;
    else {
      vis[sx][sy] = 1;
      ans++;
      if (sx > 0 && grid[sx - 1][sy] == '.')
        q.push_front(Node{sx - 1, sy, temp.x, temp.y});
      if (sx < n - 1 && grid[sx + 1][sy] == '.')
        q.push_front(Node{sx + 1, sy, temp.x, temp.y});
      if (sy > 0 && grid[sx][sy - 1] == '.' && temp.x != 0)
        q.push_back(Node{sx, sy - 1, temp.x - 1, temp.y});
      if (sy < m - 1 && grid[sx][sy + 1] == '.' && temp.y != 0)
        q.push_back(Node{sx, sy + 1, temp.x, temp.y - 1});
    }
  }
  cout << ans;
}
