#include <bits/stdc++.h>
using namespace std;
char grid[4000][4000];
void solve(long long n, long long m, long long sx, long long sy, long long x,
           long long y) {
  long long dist[n][m];
  long long dist2[n][m];
  long long val = (x > y ? -1 : 1);
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> grid[i][j];
      dist[i][j] = 1000000009;
      dist2[i][j] = 1000000009;
    }
  }
  vector<pair<long long, long long>> dir{{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) cin >> grid[i][j];
  }
  dist[sx][sy] = 0;
  dist2[sx][sy] = 0;
  auto cango = [&](long long row, long long col) {
    return (row >= 0 && row < n && col >= 0 && col < m &&
            grid[row][col] == '.');
  };
  deque<pair<pair<long long, long long>, long long>> q;
  q.push_front({{sx, sy}, 0});
  dist[sx][sy] = 0;
  while (!q.empty()) {
    pair<pair<long long, long long>, long long> p = q.front();
    long long row = p.first.first, col = p.first.second, cur_d = p.second;
    q.pop_front();
    for (pair<long long, long long> move : dir) {
      long long new_row = row + move.first, new_col = col + move.second;
      long long weight = ((move.first == 0 && move.second == -1) ? 1 : 0);
      if (cango(new_row, new_col)) {
        if (weight + cur_d < dist[new_row][new_col]) {
          dist[new_row][new_col] = cur_d + weight;
          if (weight == 1)
            q.push_back({{new_row, new_col}, dist[new_row][new_col]});
          else
            q.push_front({{new_row, new_col}, dist[new_row][new_col]});
        }
      }
    }
  }
  deque<pair<pair<long long, long long>, long long>> q2;
  q2.push_front({{sx, sy}, 0});
  dist2[sx][sy] = 0;
  while (!q2.empty()) {
    pair<pair<long long, long long>, long long> p = q2.front();
    long long row = p.first.first, col = p.first.second, cur_d = p.second;
    q2.pop_front();
    for (pair<long long, long long> move : dir) {
      long long new_row = row + move.first, new_col = col + move.second;
      long long weight = ((move.first == 0 && move.second == 1) ? 1 : 0);
      if (cango(new_row, new_col)) {
        if (weight + cur_d < dist2[new_row][new_col]) {
          dist2[new_row][new_col] = cur_d + weight;
          if (weight == 1)
            q2.push_back({{new_row, new_col}, dist2[new_row][new_col]});
          else
            q2.push_front({{new_row, new_col}, dist2[new_row][new_col]});
        }
      }
    }
  }
  long long cnt = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (dist[i][j] <= x && dist2[i][j] <= y) cnt++;
    }
  }
  cout << cnt << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  long long sx, sy;
  cin >> sx >> sy;
  sx -= 1;
  sy -= 1;
  long long x, y;
  cin >> x >> y;
  solve(n, m, sx, sy, x, y);
  return 0;
}
