#include <bits/stdc++.h>
using namespace std;
const int N = 2005, M = N * N;
int n, m;
string s[N];
bool isvalid(int x, int y) {
  return 0 <= x && x < n && 0 <= y && y < m && s[x][y] == '.';
}
int id(int x, int y) { return x * N + y; }
int par[M];
void init() {
  for (int i = 0; i < M; i++) par[i] = i;
}
int find(int u) {
  if (par[u] == u) return u;
  return par[u] = find(par[u]);
}
void merge(int u, int v) { par[find(u)] = find(v); }
vector<int> adj[M];
bool vis[M];
int dis[M];
void bfs(int s) {
  dis[s] = 0;
  vis[s] = 1;
  queue<int> q;
  q.push(s);
  while (q.size()) {
    int u = q.front();
    q.pop();
    for (int v : adj[u])
      if (!vis[v]) {
        vis[v] = 1;
        dis[v] = 1 + dis[u];
        q.push(v);
      }
  }
}
int main() {
  init();
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  int sx, sy, l, r;
  cin >> sx >> sy >> l >> r;
  sx--;
  sy--;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (s[i][j] != '.') continue;
      if (isvalid(i + 1, j)) merge(id(i, j), id(i + 1, j));
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (s[i][j] != '.') continue;
      int u = find(id(i, j));
      int l = find(id(i, j - 1));
      int r = find(id(i, j + 1));
      if (isvalid(i, j - 1)) adj[u].push_back(l);
      if (isvalid(i, j + 1)) adj[u].push_back(r);
    }
  bfs(find(id(sx, sy)));
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      int k = find(id(i, j));
      if (s[i][j] != '.' || !vis[k]) continue;
      int dif = j - sy;
      int sum = dis[k];
      assert(sum % 2 == abs(dif) % 2);
      int rr = (sum + dif) / 2;
      int ll = (sum - dif) / 2;
      if (rr <= r && ll <= l) ans++;
    }
  cout << ans << endl;
}
