#include <bits/stdc++.h>
using namespace std;
struct position {
  long long int row;
  long long int col;
  long long int left;
  long long int right;
};
int main() {
  long long int n, m;
  long long int r, c;
  long long int x, y;
  cin >> n >> m;
  cin >> r >> c;
  cin >> x >> y;
  vector<string> labyrinth;
  vector<vector<long long int> > visited(n, vector<long long int>(m, 0));
  for (long long int i = 0; i < n; i++) {
    string temp;
    cin >> temp;
    labyrinth.push_back(temp);
  }
  deque<position> q;
  long long int ans = 0;
  if (labyrinth[r - 1][c - 1] == '.') {
    q.push_back({r - 1, c - 1, x, y});
  }
  while (!q.empty()) {
    position temp = q.front();
    q.pop_front();
    if (visited[temp.row][temp.col] == 0) {
      visited[temp.row][temp.col] = 1;
      ans += 1;
      if (temp.row != 0 && labyrinth[temp.row - 1][temp.col] == '.') {
        q.push_front({temp.row - 1, temp.col, temp.left, temp.right});
      }
      if (temp.row != n - 1 && labyrinth[temp.row + 1][temp.col] == '.') {
        q.push_front({temp.row + 1, temp.col, temp.left, temp.right});
      }
      if (temp.col != 0 && labyrinth[temp.row][temp.col - 1] == '.' &&
          temp.left > 0) {
        q.push_back({temp.row, temp.col - 1, temp.left - 1, temp.right});
      }
      if (temp.col != m - 1 && labyrinth[temp.row][temp.col + 1] == '.' &&
          temp.right > 0) {
        q.push_back({temp.row, temp.col + 1, temp.left, temp.right - 1});
      }
    }
  }
  cout << ans << endl;
}
