#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int b, v;
  cin >> b >> v;
  b--;
  v--;
  int x, y;
  cin >> x >> y;
  string s[n];
  for (int i = 0; i < n; i++) cin >> s[i];
  deque<pair<int, int>> q;
  q.push_front(make_pair(b, v));
  int w[n][m];
  int vis[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      w[i][j] = INT_MAX;
      vis[i][j] = 0;
    }
  }
  w[b][v] = 0;
  while (q.size() > 0) {
    int i = q.front().first;
    int j = q.front().second;
    q.pop_front();
    if (vis[i][j] == 1) continue;
    vis[i][j] = 1;
    if (i - 1 >= 0) {
      if (vis[i - 1][j] == 0 && s[i - 1][j] == '.') {
        if (w[i - 1][j] > w[i][j]) {
          w[i - 1][j] = w[i][j];
          q.push_front(make_pair(i - 1, j));
        }
      }
    }
    if (j + 1 <= m - 1) {
      if (vis[i][j + 1] == 0 && s[i][j + 1] == '.') {
        if (w[i][j + 1] > w[i][j]) {
          w[i][j + 1] = w[i][j];
          q.push_front(make_pair(i, j + 1));
        }
      }
    }
    if (i + 1 <= n - 1) {
      if (vis[i + 1][j] == 0 && s[i + 1][j] == '.') {
        if (w[i + 1][j] > w[i][j]) {
          w[i + 1][j] = w[i][j];
          q.push_front(make_pair(i + 1, j));
        }
      }
    }
    if (j - 1 >= 0) {
      if (vis[i][j - 1] == 0 && s[i][j - 1] == '.') {
        if (w[i][j - 1] > w[i][j] + 1) {
          w[i][j - 1] = w[i][j] + 1;
          q.push_back(make_pair(i, j - 1));
        }
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (w[i][j] != INT_MAX) {
        if (w[i][j] <= x) {
          int r = w[i][j] + j - v;
          if (r >= 0 && r <= y) ans++;
        }
      }
    }
  }
  cout << ans;
}
