#include <bits/stdc++.h>
using namespace std;
int n, m;
int r, c;
int x, y;
char grid[2005][2005];
bool visited[2005][2005];
int left_distance[2005][2005];
int right_distance[2005][2005];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
bool valid(int row, int col) {
  return (row >= 0 and row < n and col >= 0 and col < m and
          grid[row][col] == '.');
}
void bfs(int ro, int co) {
  left_distance[ro][co] = right_distance[ro][co] = 0;
  visited[ro][co] = true;
  deque<pair<int, int> > dq;
  dq.push_front(make_pair(ro, co));
  while (!dq.empty()) {
    int row = dq.front().first;
    int col = dq.front().second;
    dq.pop_front();
    if (valid(row + 1, col) and visited[row + 1][col] == false) {
      dq.push_front(make_pair(row + 1, col));
      visited[row + 1][col] = true;
      left_distance[row + 1][col] = left_distance[row][col];
      right_distance[row + 1][col] = right_distance[row][col];
    }
    if (valid(row - 1, col) and visited[row - 1][col] == false) {
      dq.push_front(make_pair(row - 1, col));
      visited[row - 1][col] = true;
      left_distance[row - 1][col] = left_distance[row][col];
      right_distance[row - 1][col] = right_distance[row][col];
    }
    if (valid(row, col + 1) and
        (visited[row][col + 1] == false or
         right_distance[row][col + 1] >= right_distance[row][col] + 1)) {
      dq.push_back(make_pair(row, col + 1));
      visited[row][col + 1] = true;
      left_distance[row][col + 1] = left_distance[row][col];
      right_distance[row][col + 1] = right_distance[row][col] + 1;
    }
    if (valid(row, col - 1) and
        (visited[row][col - 1] == false or
         left_distance[row][col - 1] >= left_distance[row][col] + 1)) {
      dq.push_back(make_pair(row, col - 1));
      visited[row][col - 1] = true;
      right_distance[row][col - 1] = right_distance[row][col];
      left_distance[row][col - 1] = left_distance[row][col] + 1;
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> r >> c >> x >> y;
  r--;
  c--;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> grid[i][j];
      left_distance[i][j] = right_distance[i][j] = 2e9;
    }
  }
  bfs(r, c);
  int count = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (left_distance[i][j] <= x and right_distance[i][j] <= y) count++;
    }
  }
  cout << count << endl;
  return 0;
}
