#include <bits/stdc++.h>
using namespace std;
vector<string> adj;
int n, m;
bool ok(int x, int y) {
  if (x >= 0 && x < n && y >= 0 && y < m && adj[x][y] == '.') return true;
  return false;
}
struct node {
  int left;
  int right;
  int x;
  int y;
  int dis;
  node(int a, int b, int c, int d, int e) {
    left = a;
    right = b;
    x = d;
    y = e;
    dis = c;
  }
  void p() {
    cerr << x << " " << y << " " << dis << " " << left << " " << right << endl;
  }
};
void solve() {
  cin >> n >> m;
  int sx, sy;
  cin >> sx >> sy;
  int maxl;
  int maxr;
  cin >> maxl >> maxr;
  sx--, sy--;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    adj.push_back(s);
  }
  if (adj[sx][sy] == '*') {
    cout << 0 << endl;
    return;
  }
  int dist[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) dist[i][j] = 1e9;
  }
  dist[sx][sy] = 0;
  deque<node> q;
  q.push_back(node(0, 0, 0, sx, sy));
  int cnt = 0;
  while (!q.empty()) {
    node a = q.front();
    q.pop_front();
    if (ok(a.x - 1, a.y) && dist[a.x - 1][a.y] > dist[a.x][a.y]) {
      dist[a.x - 1][a.y] = dist[a.x][a.y];
      q.push_front(node(a.left, a.right, dist[a.x - 1][a.y], a.x - 1, a.y));
    }
    if (ok(a.x + 1, a.y) && dist[a.x + 1][a.y] > dist[a.x][a.y]) {
      dist[a.x + 1][a.y] = dist[a.x][a.y];
      q.push_front(node(a.left, a.right, dist[a.x + 1][a.y], a.x + 1, a.y));
    }
    if (ok(a.x, a.y - 1) && dist[a.x][a.y - 1] > dist[a.x][a.y] + 1 &&
        a.left + 1 <= maxl) {
      dist[a.x][a.y - 1] = dist[a.x][a.y] + 1;
      q.push_back(node(a.left + 1, a.right, dist[a.x][a.y - 1], a.x, a.y - 1));
    }
    if (ok(a.x, a.y + 1) && dist[a.x][a.y + 1] > dist[a.x][a.y] + 1 &&
        a.right + 1 <= maxr) {
      dist[a.x][a.y + 1] = dist[a.x][a.y] + 1;
      q.push_back(node(a.left, a.right + 1, dist[a.x][a.y + 1], a.x, a.y + 1));
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (dist[i][j] != 1e9) ans++;
    }
  }
  cout << ans << endl;
}
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
