#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};
char s[N][N];
struct node {
  int x, y, ll, lr;
  bool operator<(const node &nd) const { return ll + lr < nd.ll + nd.lr; }
} tem, tt;
priority_queue<node> q;
bool v[N][N];
int main() {
  int n, m, x, y;
  scanf("%d%d", &n, &m);
  scanf("%d%d", &tem.x, &tem.y);
  scanf("%d%d", &tem.ll, &tem.lr);
  for (int i = 1; i <= n; ++i) scanf("%s", s[i] + 1);
  q.push(tem);
  v[tem.x][tem.y] = 1;
  while (!q.empty()) {
    tem = q.top();
    q.pop();
    for (int i = 0; i < 4; ++i) {
      tt.x = tem.x + dx[i];
      tt.y = tem.y + dy[i];
      tt.ll = tem.ll;
      tt.lr = tem.lr;
      if (i == 2)
        tt.ll--;
      else if (i == 3)
        tt.lr--;
      if (tt.ll < 0 || tt.lr < 0) continue;
      if (tt.x <= n && tt.x >= 1 && tt.y >= 1 && tt.y <= m && !v[tt.x][tt.y] &&
          s[tt.x][tt.y] == '.') {
        v[tt.x][tt.y] = 1;
        q.push(tt);
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      if (v[i][j]) ++ans;
    }
  }
  printf("%d\n", ans);
  return 0;
}
