#include <bits/stdc++.h>
using namespace std;
int n, m, vis[2001][2001], r, c, x, y, ans;
char a[2001][2001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> r >> c >> x >> y;
  r--;
  c--;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cin >> a[i][j];
  }
  priority_queue<pair<pair<int, int>, pair<int, int> >,
                 vector<pair<pair<int, int>, pair<int, int> > >,
                 greater<pair<pair<int, int>, pair<int, int> > > >
      q;
  q.push({{0, 0}, {r, c}});
  while (!q.empty()) {
    int l = q.top().first.first;
    int r = q.top().first.second;
    int xx = q.top().second.first;
    int yy = q.top().second.second;
    q.pop();
    if (vis[xx][yy]) continue;
    vis[xx][yy] = 1;
    if (yy + 1 < m && a[xx][yy + 1] == '.' && r < y && !vis[xx][yy + 1])
      q.push({{l, r + 1}, {xx, yy + 1}});
    if (yy - 1 >= 0 && a[xx][yy - 1] == '.' && l < x && !vis[xx][yy - 1])
      q.push({{l + 1, r}, {xx, yy - 1}});
    if (xx - 1 >= 0 && a[xx - 1][yy] == '.' && !vis[xx - 1][yy])
      q.push({{l, r}, {xx - 1, yy}});
    if (xx + 1 < n && a[xx + 1][yy] == '.' && !vis[xx + 1][yy])
      q.push({{l, r}, {xx + 1, yy}});
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++)
      if (vis[i][j]) ans++;
  }
  cout << ans;
}
