#include <bits/stdc++.h>
using namespace std;
const int N = 2000;
int n, m, r, c, x, y, dl[N][N], dr[N][N];
string maze[N];
bool valid(int i, int j) {
  return i >= 0 && i < n && j >= 0 && j < m && maze[i][j] == '.' &&
         dl[i][j] == -1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> r >> c >> x >> y;
  r--, c--;
  for (int i = 0; i < n; i++) cin >> maze[i];
  deque<pair<int, int> > q;
  memset(dl, -1, sizeof dl);
  memset(dr, -1, sizeof dr);
  q.push_back({r, c});
  dl[r][c] = 0;
  dr[r][c] = 0;
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop_front();
    int i = p.first, j = p.second;
    if (valid(i - 1, j)) {
      q.push_front({i - 1, j});
      dl[i - 1][j] = dl[i][j];
      dr[i - 1][j] = dr[i][j];
    }
    if (valid(i + 1, j)) {
      q.push_front({i + 1, j});
      dl[i + 1][j] = dl[i][j];
      dr[i + 1][j] = dr[i][j];
    }
    if (valid(i, j - 1)) {
      q.push_back({i, j - 1});
      dl[i][j - 1] = dl[i][j] + 1;
      dr[i][j - 1] = dr[i][j];
    }
    if (valid(i, j + 1)) {
      q.push_back({i, j + 1});
      dl[i][j + 1] = dl[i][j];
      dr[i][j + 1] = dr[i][j] + 1;
    }
  }
  int result = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (dl[i][j] != -1 && dl[i][j] <= x && dr[i][j] <= y) result++;
  cout << result << endl;
}
