#include <bits/stdc++.h>
using namespace std;
const int N = 5e3;
bool usd[N][N];
pair<int, int> d[N][N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, m;
  cin >> n >> m;
  int r, sc;
  cin >> r >> sc;
  int first, second;
  cin >> first >> second;
  char c[n + 1][m + 1];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> c[i][j];
  deque<pair<int, int> > q;
  q.push_front({r, sc});
  d[r][sc] = {0, 0};
  usd[r][sc] = 1;
  int cnt = 0;
  while (!q.empty()) {
    pair<int, int> cur = q.front();
    int i = cur.first;
    int j = cur.second;
    cnt++;
    q.pop_front();
    if (i > 1)
      if (c[i - 1][j] == '.' && !usd[i - 1][j]) {
        q.push_front({i - 1, j});
        usd[i - 1][j] = 1;
        d[i - 1][j] = d[i][j];
      }
    if (i < n)
      if (c[i + 1][j] == '.' && !usd[i + 1][j]) {
        q.push_front({i + 1, j});
        usd[i + 1][j] = 1;
        d[i + 1][j] = d[i][j];
      };
    if (j > 1)
      if (c[i][j - 1] == '.' && !usd[i][j - 1] && d[i][j].first != first) {
        q.push_back({i, j - 1});
        d[i][j - 1] = d[i][j];
        d[i][j - 1].first++;
        usd[i][j - 1] = 1;
      }
    if (j < m)
      if (c[i][j + 1] == '.' && !usd[i][j + 1] && d[i][j].second != second) {
        q.push_back({i, j + 1});
        d[i][j + 1] = d[i][j];
        d[i][j + 1].second++;
        usd[i][j + 1] = 1;
      }
  }
  cout << cnt;
}
