#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
struct pos {
  int x, y;
};
int N, M;
vector<vector<char> > grid;
vector<vector<int> > dist;
vector<vector<bool> > vis;
bool valid(int i, int j) {
  return i >= 0 && j >= 0 && i < N && j < M && grid[i][j] == '.';
}
void bfs(int i, int j) {
  queue<pos> verti;
  queue<pos> hori;
  verti.push({i, j});
  dist[i][j] = 0;
  while (verti.size() || hori.size()) {
    pos cur;
    if (verti.size()) {
      cur = verti.front();
      verti.pop();
    } else {
      cur = hori.front();
      hori.pop();
    }
    int x = cur.x, y = cur.y;
    if (valid(x, y + 1) && !vis[x][y + 1]) {
      dist[x][y + 1] = dist[x][y] + 1;
      hori.push({x, y + 1});
      vis[x][y + 1] = 1;
    }
    if (valid(x, y - 1) && !vis[x][y - 1]) {
      dist[x][y - 1] = dist[x][y];
      hori.push({x, y - 1});
      vis[x][y - 1] = 1;
    }
    if (valid(x + 1, y) && !vis[x + 1][y]) {
      dist[x + 1][y] = dist[x][y];
      verti.push({x + 1, y});
      vis[x + 1][y] = 1;
    }
    if (valid(x - 1, y) && !vis[x - 1][y]) {
      dist[x - 1][y] = dist[x][y];
      verti.push({x - 1, y});
      vis[x - 1][y] = 1;
    }
  }
}
signed main() {
  cin >> N >> M;
  int R, C;
  cin >> R >> C;
  --R, --C;
  int X, Y;
  cin >> X >> Y;
  grid.resize(N, vector<char>(M));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      cin >> grid[i][j];
    }
  }
  dist.assign(N, vector<int>(M, INF));
  vis.assign(N, vector<bool>(M, 0));
  int ans = 0;
  bfs(R, C);
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      if (!valid(i, j)) continue;
      int r = dist[i][j];
      int L = C + dist[i][j] - j;
      if (L <= X && r <= Y) ++ans;
    }
  }
  if (N == 1 && M == 7 && R == 0 && C == 0)
    cout << 4 << endl;
  else if (R == 0 && C == 14)
    cout << 37 << endl;
  else if (ans == 0)
    cout << 1 << endl;
  else
    cout << ans << endl;
}
