#include <bits/stdc++.h>
using namespace std;
int l, r, x, y, n, m, cnt = 0;
int** L;
int** R;
int** v;
char** a;
int main() {
  scanf("%d %d %d %d %d %d ", &n, &m, &x, &y, &l, &r);
  L = (int**)malloc(n * sizeof(int*));
  R = (int**)malloc(n * sizeof(int*));
  v = (int**)malloc(n * sizeof(int*));
  a = (char**)malloc(n * sizeof(char*));
  for (int i = 0; i < n; ++i) {
    L[i] = (int*)calloc(m, sizeof(int));
    R[i] = (int*)calloc(m, sizeof(int));
    v[i] = (int*)calloc(m, sizeof(int));
    a[i] = (char*)calloc(m, sizeof(char));
    for (int j = 0; j < m; ++j) {
      scanf("%c", &a[i][j]);
      L[i][j] = -1;
      R[i][j] = -1;
    }
    scanf(" ");
  }
  deque<pair<int, int>> q;
  q.push_back({x - 1, y - 1});
  L[x - 1][y - 1] = 0;
  R[x - 1][y - 1] = 0;
  while (!q.empty()) {
    auto cur = q.front();
    q.pop_front();
    x = cur.first;
    y = cur.second;
    v[x][y] = 1;
    int _x, _y;
    _x = x + 1, _y = y;
    if (_x >= 0 && _x < n && _y >= 0 && _y < m && a[_x][_y] == '.') {
      int nR = R[x][y];
      int nL = L[x][y];
      if ((R[_x][_y] == -1 && L[_x][_y] == -1) ||
          (L[_x][_y] > nL && R[_x][_y] > nR)) {
        R[_x][_y] = nR;
        L[_x][_y] = nL;
        q.push_back({_x, _y});
      }
    }
    _x = x - 1, _y = y;
    if (_x >= 0 && _x < n && _y >= 0 && _y < m && a[_x][_y] == '.') {
      int nR = R[x][y];
      int nL = L[x][y];
      if ((R[_x][_y] == -1 && L[_x][_y] == -1) ||
          (L[_x][_y] > nL && R[_x][_y] > nR)) {
        R[_x][_y] = nR;
        L[_x][_y] = nL;
        q.push_back({_x, _y});
      }
    }
    _x = x, _y = y + 1;
    if (_x >= 0 && _x < n && _y >= 0 && _y < m && a[_x][_y] == '.' &&
        R[x][y] < r) {
      int nR = R[x][y] + 1;
      int nL = L[x][y];
      if ((R[_x][_y] == -1 && L[_x][_y] == -1) ||
          (L[_x][_y] > nL && R[_x][_y] > nR)) {
        R[_x][_y] = nR;
        L[_x][_y] = nL;
        q.push_back({_x, _y});
      }
    }
    _x = x, _y = y - 1;
    if (_x >= 0 && _x < n && _y >= 0 && _y < m && a[_x][_y] == '.' &&
        L[x][y] < l) {
      int nR = R[x][y];
      int nL = L[x][y] + 1;
      if ((R[_x][_y] == -1 && L[_x][_y] == -1) ||
          (L[_x][_y] > nL && R[_x][_y] > nR)) {
        R[_x][_y] = nR;
        L[_x][_y] = nL;
        q.push_back({_x, _y});
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (v[i][j] == 1) cnt++;
    }
    free(L[i]);
    free(R[i]);
    free(a[i]);
    free(v[i]);
  }
  printf("%d\n", cnt);
  free(L);
  free(R);
  free(a);
  free(v);
  return 0;
}
