#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 2e3 + 5;
const int mod = 1e9 + 7;
int xx[] = {-1, 1, 0, 0};
int yy[] = {0, 0, -1, 1};
int n, m;
char mp[N][N];
struct node {
  int x, y, l, r;
  node(int xx, int yy, int ll, int rr) { x = xx, y = yy, l = ll, r = rr; }
};
bool ok(int x, int y) {
  if (x < 1 || x > n || y < 1 || y > m || mp[x][y] == '*') return 0;
  return 1;
}
deque<node> q;
bool vis[N][N];
int main() {
  int r, c, x, y;
  cin >> n >> m >> r >> c >> x >> y;
  for (int i = 1; i <= n; i++) {
    scanf("%s", mp[i] + 1);
  }
  q.push_front(node(r, c, 0, 0));
  vis[r][c] = 1;
  int ans = 0;
  while (!q.empty()) {
    node tmp = q.front();
    q.pop_front();
    ans++;
    for (int i = 0; i < 4; i++) {
      if (!ok(tmp.x + xx[i], tmp.y + yy[i]) ||
          vis[tmp.x + xx[i]][tmp.y + yy[i]] || (i == 2 && tmp.l == x) ||
          (i == 3 && tmp.r == y))
        continue;
      vis[tmp.x + xx[i]][tmp.y + yy[i]] = 1;
      if (i <= 1)
        q.push_front(node(tmp.x + xx[i], tmp.y + yy[i], tmp.l, tmp.r));
      else
        q.push_back(node(tmp.x + xx[i], tmp.y + yy[i], tmp.l + (i == 2),
                         tmp.r + (i == 3)));
    }
  }
  cout << ans << endl;
  return 0;
}
