#include <bits/stdc++.h>
using namespace std;
const char VISITED = '+';
const char UNVISITED = '.';
const char BLOCKED = '*';
const int INF = 1000000000;
int lmax[2000][2000] = {0};
int rmax[2000][2000] = {0};
int visited[2000][2000] = {0};
int main() {
  int n, m;
  cin >> n >> m;
  int r, c;
  cin >> r >> c;
  r--;
  c--;
  int left, right;
  cin >> left >> right;
  vector<string> maze(n);
  for (int i = 0; i < n; i++) {
    cin >> maze[i];
  }
  int start = r * m + c;
  queue<pair<pair<int, int>, pair<int, int> > > q;
  q.push(pair<pair<int, int>, pair<int, int> >(pair<int, int>(0, start),
                                               pair<int, int>(left, right)));
  int dx[] = {0, 0, -1, 1};
  int dy[] = {-1, 1, 0, 0};
  int res = 0;
  while (!q.empty()) {
    pair<pair<int, int>, pair<int, int> > x = q.front();
    q.pop();
    int row = x.first.second / m;
    int col = x.first.second % m;
    int rleft = x.second.first;
    int rright = x.second.second;
    if (rleft < 0 || rright < 0) continue;
    if ((maze[row][col] == VISITED && -rright >= rmax[row][col] &&
         -rleft >= lmax[row][col]) ||
        maze[row][col] == BLOCKED)
      continue;
    maze[row][col] = VISITED;
    if (visited[row][col] == 0) res++;
    visited[row][col] = 1;
    lmax[row][col] = -rleft;
    rmax[row][col] = -rright;
    for (int i = 0; i < 4; i++) {
      if (row + dy[i] < 0 || row + dy[i] >= n || col + dx[i] < 0 ||
          col + dx[i] >= m || maze[row + dy[i]][col + dx[i]] == BLOCKED)
        continue;
      q.push(pair<pair<int, int>, pair<int, int> >(
          pair<int, int>(-abs(dx[i]), (row + dy[i]) * m + col + dx[i]),
          pair<int, int>(min(rleft, rleft + dx[i]),
                         min(rright, rright - dx[i]))));
    }
  }
  cout << res << endl;
  return 0;
}
