#include <bits/stdc++.h>
using namespace std;
int n, m, sx, sy, ans;
char c[2005][2005];
bool b[2005][2005];
long long l, r;
void no(int i, int j, long long l, long long r) {
  deque<pair<pair<long long, long long>, pair<long long, long long> > > q;
  q.push_front({{i, j}, {l, r}});
  b[i][j] = 1;
  while (q.size()) {
    long long i = q.front().first.first, j = q.front().first.second,
              l = q.front().second.first, r = q.front().second.second;
    q.pop_front();
    ans++;
    if (i < n && c[i + 1][j] == '.' && !b[i + 1][j]) {
      b[i + 1][j] = 1;
      q.push_front({{i + 1, j}, {l, r}});
    }
    if (i > 1 && c[i - 1][j] == '.' && !b[i - 1][j]) {
      b[i - 1][j] = 1;
      q.push_front({{i - 1, j}, {l, r}});
    }
    if (j < m && c[i][j + 1] == '.' && !b[i][j + 1] && r > 0) {
      b[i][j + 1] = 1;
      q.push_back({{i, j + 1}, {l, r - 1}});
    }
    if (j > 1 && c[i][j - 1] == '.' && !b[i][j - 1] && l > 0) {
      b[i][j - 1] = 1;
      q.push_back({{i, j - 1}, {l - 1, r}});
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m >> sx >> sy >> l >> r;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> c[i][j];
    }
  }
  no(sx, sy, l, r);
  cout << ans;
  return 0;
}
