#include <bits/stdc++.h>
using namespace std;
struct s {
  int x, y, x1, y1;
};
int main() {
  int n, m, r, c, x, y;
  cin >> n >> m >> r >> c >> x >> y;
  vector<vector<char>> a(n, vector<char>(m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
    }
  }
  deque<s> q;
  q.push_back({r - 1, c - 1, x, y});
  vector<vector<bool>> used(n, vector<bool>(m, false));
  int res = 0;
  while (!q.empty()) {
    s v = q.front();
    q.pop_front();
    if (!used[v.x][v.y]) {
      used[v.x][v.y] = 1;
      if (v.x1 > 0 && v.y > 0 && a[v.x][v.y - 1] == '.') {
        q.push_back({v.x, v.y - 1, v.x1 - 1, v.y1});
      }
      if (v.y1 > 0 && v.y < m - 1 && a[v.x][v.y + 1] == '.') {
        q.push_back({v.x, v.y + 1, v.x1, v.y1 - 1});
      }
      if (v.x > 0 && a[v.x - 1][v.y] == '.') {
        q.push_front({v.x - 1, v.y, v.x1, v.y1});
      }
      if (v.x < n - 1 && a[v.x + 1][v.y] == '.') {
        q.push_front({v.x + 1, v.y, v.x1, v.y1});
      }
      res += 1;
    }
  }
  cout << res;
}
