#include <bits/stdc++.h>
using namespace std;
const long long M = 1e9 + 7;
long long dx[4] = {0, 0, -1, 1};
long long dy[4] = {-1, 1, 0, 0};
void solve() {
  long long n, m;
  cin >> n >> m;
  long long vis[n][m];
  memset(vis, 0, sizeof(vis));
  pair<long long, long long> p[n][m];
  long long ans = 0;
  long long r, c;
  cin >> r >> c;
  r--, c--;
  deque<pair<long long, long long>> q;
  q.push_front({r, c});
  vis[r][c] = 1;
  p[r][c] = {0, 0};
  long long mxl, mxr;
  cin >> mxl >> mxr;
  string s[n];
  for (long long i = 0; i < n; i++) cin >> s[i];
  while (!q.empty()) {
    ans++;
    long long x = q.front().first;
    long long y = q.front().second;
    long long l = p[x][y].first;
    long long r = p[x][y].second;
    q.pop_front();
    for (long long i = 0; i < 4; i++) {
      long long X = x + dx[i];
      long long Y = y + dy[i];
      if (X >= 0 && X < n && Y >= 0 && Y < m && s[X][Y] == '.' && !vis[X][Y]) {
        if (i == 0 && l == mxl) continue;
        if (i == 1 && r == mxr) continue;
        vis[X][Y] = 1;
        p[X][Y] = {l, r};
        if (i == 0) {
          p[X][Y].first++;
          q.push_back({X, Y});
          continue;
        }
        if (i == 1) p[X][Y].second++;
        q.push_front({X, Y});
      }
    }
  }
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long t = 1;
  while (t--) {
    solve();
  }
}
