#include <bits/stdc++.h>
using namespace std;
queue<pair<int, int>> q;
int n, m, sx, sy, vis[2007][2007];
char s[2007][2007];
int xd[3] = {1, -1, 0}, yd[3] = {0, 0, -1};
int check(int x, int y) {
  return x >= 1 && x <= n && y >= 1 && y <= m && s[x][y] == '.';
}
void dfs(int ux, int uy, int x) {
  q.push(make_pair(ux, uy)), vis[ux][uy] = x;
  for (int i = 0; i < 3; i++) {
    int vx = ux + xd[i], vy = uy + yd[i];
    if (check(vx, vy) && vis[vx][vy] == -1) dfs(vx, vy, x);
  }
}
void bfs() {
  memset(vis, -1, sizeof(vis));
  if (check(sx, sy)) dfs(sx, sy, 0);
  while (!q.empty()) {
    int ux = q.front().first, uy = q.front().second;
    q.pop();
    if (check(ux, uy + 1) && vis[ux][uy + 1] == -1) {
      dfs(ux, uy + 1, vis[ux][uy] + 1);
    }
  }
}
int main() {
  cin >> n >> m;
  cin >> sx >> sy;
  int lx, ly;
  cin >> lx >> ly;
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  int ans = 0;
  bfs();
  for (int i = 1; i <= n; i++) {
    for (int k = 1; k <= m; k++) {
      if (s[i][k] == '.' && vis[i][k] != -1) {
        int x = sy + vis[i][k] - k, y = vis[i][k];
        if (x <= lx && y <= ly) ans++;
      }
    }
  }
  cout << ans;
  return 0;
}
