#include <bits/stdc++.h>
using namespace std;
const int N = 2005, INF = 1e9;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
pair<int, int> dis[N][N];
bool done[N][N];
string g[N];
int n, m, sx, sy, L, R;
bool valid(int x, int y) {
  return x >= 0 && x < n && y >= 0 && y < m && g[x][y] == '.';
}
void solve(bool fs) {
  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>>>>
      pq;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) dis[i][j] = {INF, INF};
  dis[sx][sy] = {0, 0};
  pq.push({{0, 0}, {sx, sy}});
  while (!pq.empty()) {
    int x = pq.top().second.first;
    int y = pq.top().second.second;
    pair<int, int> d = pq.top().first;
    pq.pop();
    if (dis[x][y] < d) continue;
    if (fs && dis[x][y].first <= L && dis[x][y].second <= R) done[x][y] = 1;
    if ((!fs) && dis[x][y].first <= R && dis[x][y].second <= L) done[x][y] = 1;
    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i], ny = y + dy[i];
      if (valid(nx, ny)) {
        pair<int, int> p = {0, 0};
        if (dy[i] < 0) {
          if (fs)
            p = {1, 0};
          else
            p = {0, 1};
        }
        if (dy[i] > 0) {
          if (fs)
            p = {0, 1};
          else
            p = {1, 0};
        }
        pair<int, int> np = {d.first + p.first, d.second + p.second};
        if (np < dis[nx][ny]) {
          dis[nx][ny] = np;
          pq.push({np, {nx, ny}});
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  cin >> sx >> sy;
  sx--;
  sy--;
  cin >> L >> R;
  for (int i = 0; i < n; i++) cin >> g[i];
  solve(0);
  solve(1);
  int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) ans += done[i][j];
  cout << ans << endl;
  return 0;
}
