#include <bits/stdc++.h>
using namespace std;
constexpr int MAXN = 2000;
constexpr int MAXM = 2000;
int n, m;
int ret = 0;
int maxr, maxl;
bool visited[MAXN][MAXM];
char level[MAXN][MAXM];
void dijkstra(int startr, int startc) {
  std::priority_queue<tuple<int, int, int, int, int>> q;
  q.push({0, maxl, maxr, startr, startc});
  while (!q.empty()) {
    auto [dist, lleft, rleft, row, col] = q.top();
    dist = -dist;
    q.pop();
    if (visited[row][col]) continue;
    if (lleft < 0 || rleft < 0) continue;
    visited[row][col] = true;
    ++ret;
    for (int i = -1; i <= 1; i += 2) {
      int newRow = row + i;
      if (!(0 <= newRow && newRow < n)) continue;
      if (visited[newRow][col]) continue;
      if (level[newRow][col] == '*') continue;
      q.push({-dist, lleft, rleft, newRow, col});
    }
    for (int i = -1; i <= 1; i += 2) {
      int newCol = col + i;
      if (!(0 <= newCol && newCol < m)) continue;
      if (visited[row][newCol]) continue;
      if (level[row][newCol] == '*') continue;
      q.push({-(dist + 1), lleft - (i == -1), rleft - (i == 1), row, newCol});
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  int r, c;
  cin >> n >> m >> r >> c >> maxl >> maxr;
  --r;
  --c;
  for (int i = 0; i < n; ++i) {
    cin >> level[i];
  }
  dijkstra(r, c);
  cout << ret;
  return 0;
}
