#include <bits/stdc++.h>
using namespace std;
int n, m, r, c, sx, sy, ans;
int v[2005][2005];
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
int fx[4] = {0, -1, 0, 0};
int fy[4] = {-1, 0, 0, 0};
deque<int> q, xl, yl;
int main() {
  scanf("%d%d%d%d%d%d\n", &n, &m, &r, &c, &sx, &sy);
  for (int i = 1; i <= n; i++) {
    string st;
    getline(cin, st);
    for (int j = 1; j <= m; j++)
      if (st[j - 1] == '*') v[i][j] = 1;
  }
  q.push_front(r * 10000 + c);
  xl.push_front(sx);
  yl.push_front(sy);
  v[r][c] = 2;
  ans++;
  while (!q.empty()) {
    int x = q.front();
    q.pop_front();
    int y = x % 10000;
    x = x / 10000;
    int xxl = xl.front();
    xl.pop_front();
    int yyl = yl.front();
    yl.pop_front();
    for (int i = 0; i < 4; i++) {
      int cx = dx[i] + x;
      int cy = dy[i] + y;
      if (cx > n || cx < 1 || cy > m || cy < 1) continue;
      if (xxl == 0 && i == 1) continue;
      if (yyl == 0 && i == 0) continue;
      if (v[cx][cy] != 0) continue;
      if (!v[cx][cy]) ans++;
      v[cx][cy] = 2;
      if (i >= 2) {
        q.push_front(cx * 10000 + cy);
        xl.push_front(xxl + fx[i]);
        yl.push_front(yyl + fy[i]);
      } else {
        q.push_back(cx * 10000 + cy);
        xl.push_back(xxl + fx[i]);
        yl.push_back(yyl + fy[i]);
      }
    }
  }
  printf("%d", ans);
}
