#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
typedef struct {
  int r;
  int c;
  int x;
  int y;
} node;
int n, m, r, c, x, y, cnt;
string s[2018];
bool vis[2010][2010];
deque<node> qu;
bool good(int r, int c) {
  if (0 <= r && r < n && 0 <= c && c < m && s[r][c] == '.' && !vis[r][c])
    return true;
  else
    return false;
}
void solve(int r, int c, int x, int y) {
  node tmp;
  tmp.r = r;
  tmp.c = c;
  tmp.x = x;
  tmp.y = y;
  vis[tmp.r][tmp.c] = true;
  qu.push_back(tmp);
  while (!qu.empty()) {
    tmp = qu.front();
    qu.pop_front();
    cnt++;
    r = tmp.r;
    c = tmp.c;
    x = tmp.x;
    y = tmp.y;
    if (good(r + 1, c)) {
      vis[r + 1][c] = true;
      tmp.r = r + 1;
      qu.push_front(tmp);
      tmp.r = r;
    }
    if (good(r - 1, c)) {
      tmp.r = r - 1;
      vis[tmp.r][tmp.c] = true;
      qu.push_front(tmp);
      tmp.r = r;
    }
    if (good(r, c + 1) && y > 0) {
      tmp.c = c + 1;
      tmp.y = y - 1;
      vis[tmp.r][tmp.c] = true;
      qu.push_back(tmp);
      tmp.c = c;
      tmp.y = y;
    }
    if (good(r, c - 1) && x > 0) {
      tmp.c = c - 1;
      tmp.x = x - 1;
      vis[tmp.r][tmp.c] = true;
      qu.push_back(tmp);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> r >> c >> x >> y;
  r--;
  c--;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  solve(r, c, x, y);
  cout << cnt << endl;
  return 0;
}
