#include <bits/stdc++.h>
using namespace std;
const int nax = 1e4 + 5;
const int mod = 1e9 + 7;
long long int n, m, r, c, x, y;
long long int rows[4] = {0, 0, 1, -1};
long long int cols[4] = {1, -1, 0, 0};
long long int cost[4] = {0, 1, 0, 0};
string maze[2005];
long long int dp[2005][2005];
bool isValid(long long int x, long long int y) {
  return (x >= 0 && x < n && y >= 0 && y < m && maze[x][y] == '.');
}
void solve() {
  deque<pair<long long int, long long int>> q;
  memset(dp, -1, sizeof(dp));
  dp[r][c] = 0;
  q.push_front({r, c});
  while (!q.empty()) {
    auto node = q.front();
    q.pop_front();
    long long int ci = node.first;
    long long int cj = node.second;
    for (long long int i = 0; i < 4; i++) {
      long long int ni = ci + rows[i];
      long long int nj = cj + cols[i];
      long long int len = cost[i];
      if (isValid(ni, nj)) {
        if (dp[ni][nj] == -1 || dp[ni][nj] > dp[ci][cj] + len) {
          dp[ni][nj] = dp[ci][cj] + len;
          if (len) {
            q.push_back({ni, nj});
          } else {
            q.push_front({ni, nj});
          }
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> r >> c >> x >> y;
  r--;
  c--;
  for (int i = 0; i < n; i++) {
    cin >> maze[i];
  };
  solve();
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      long long int left = dp[i][j];
      long long int right = left + j - c;
      if (left <= x && right <= y && left >= 0 && right >= 0) {
        ans++;
      }
    }
  }
  cout << ans;
}
