#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cout << *it << " = " << a << "\n";
  err(++it, args...);
}
const long long N = 2002, M = 1e9 + 7, inf = 1e18;
string s[N];
int n, m, vis[N][N];
vector<vector<long long> > d(N, vector<long long>(N, inf));
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
bool valid(int i, int j) {
  return i >= 0 and i < n and j >= 0 and j < m and s[i][j] == '.';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int r, c, x, y;
  cin >> n >> m >> r >> c >> x >> y;
  r--;
  c--;
  for (int i = 0; i < n; i++) cin >> s[i];
  ;
  deque<pair<int, int> > q;
  q.push_back({r, c});
  d[r][c] = 0;
  vis[r][c] = 1;
  while (not q.empty()) {
    int i = q.front().first, j = q.front().second;
    q.pop_front();
    for (int k = 0; k < 4; k++) {
      int ni = i + dx[k], nj = j + dy[k];
      if (valid(ni, nj)) {
        int x = (nj < j);
        if (d[ni][nj] > x + d[i][j]) {
          d[ni][nj] = x + d[i][j];
          if (x > 0) {
            q.push_back({ni, nj});
          } else {
            q.push_front({ni, nj});
          }
        }
      }
    }
  }
  int cnt = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (s[i][j] == '.') {
        cnt += d[i][j] <= x and d[i][j] + (j - c) <= y;
      }
  cout << cnt;
}
