#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 10;
pair<int, int> f[N][N];
int h[N][N], a[N][N];
int n, m, limL, limR, sx, sy;
deque<pair<int, int> > q;
int solve() {
  h[sx][sy] = 1;
  q.push_back(pair<int, int>(sx, sy));
  int ans = 0;
  while (!q.empty()) {
    pair<int, int> cur = q.front();
    q.pop_front();
    ans++;
    for (int dx = -1; dx <= 1; dx += 2) {
      if (a[cur.first + dx][cur.second] && !h[cur.first + dx][cur.second]) {
        h[cur.first + dx][cur.second] = 1;
        f[cur.first + dx][cur.second] = f[cur.first][cur.second];
        q.push_front(pair<int, int>(cur.first + dx, cur.second));
      }
    }
    if (f[cur.first][cur.second].first < limL) {
      if (a[cur.first][cur.second - 1] && !h[cur.first][cur.second - 1]) {
        h[cur.first][cur.second - 1] = 1;
        f[cur.first][cur.second - 1] = f[cur.first][cur.second];
        f[cur.first][cur.second - 1].first++;
        q.push_back(pair<int, int>(cur.first, cur.second - 1));
      }
    }
    if (f[cur.first][cur.second].second < limR) {
      if (a[cur.first][cur.second + 1] && !h[cur.first][cur.second + 1]) {
        h[cur.first][cur.second + 1] = 1;
        f[cur.first][cur.second + 1] = f[cur.first][cur.second];
        f[cur.first][cur.second + 1].second++;
        q.push_back(pair<int, int>(cur.first, cur.second + 1));
      }
    }
  }
  return ans;
}
int main() {
  cin >> n >> m;
  cin >> sx >> sy;
  cin >> limL >> limR;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    for (int j = 1; j <= m; j++) {
      a[i][j] = (s[j - 1] == '.');
    }
  }
  cout << solve();
}
