#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
char mp[maxn][maxn];
int zuo[maxn][maxn], you[maxn][maxn];
bool vis[maxn][maxn];
int cnt, n, m, r, c, x, y;
struct Node {
  int x, y;
  Node() {}
  Node(int x, int y) : x(x), y(y) {}
};
queue<Node> qu;
bool isOk(int x, int y) {
  if (x >= 1 && x <= n && y >= 1 && y <= m && mp[x][y] != '*') return true;
  return false;
}
void tonext(int zx, int zy, int i) {
  int tx = zx + dx[i], ty = zy + dy[i];
  int flagz = (dy[i] == -1);
  int flagy = (dy[i] == 1);
  if (!vis[tx][ty] || zuo[tx][ty] < zuo[zx][zy] - flagz ||
      you[tx][ty] < you[zx][zy] - flagy) {
    if (!vis[tx][ty]) {
      vis[tx][ty] = 1;
      cnt++;
      mp[tx][ty] = '+';
    }
    zuo[tx][ty] = max(zuo[tx][ty], zuo[zx][zy] - flagz);
    you[tx][ty] = max(you[tx][ty], you[zx][zy] - flagy);
    qu.push(Node(tx, ty));
  }
}
void bfs(Node st) {
  vis[st.x][st.y] = 1;
  mp[st.x][st.y] = '+';
  cnt++;
  qu.push(st);
  while (!qu.empty()) {
    Node tem = qu.front();
    qu.pop();
    if (isOk(tem.x + dx[0], tem.y + dy[0])) tonext(tem.x, tem.y, 0);
    if (isOk(tem.x + dx[1], tem.y + dy[1])) tonext(tem.x, tem.y, 1);
    if (isOk(tem.x + dx[2], tem.y + dy[2]) && you[tem.x][tem.y] >= 1)
      tonext(tem.x, tem.y, 2);
    if (isOk(tem.x + dx[3], tem.y + dy[3]) && zuo[tem.x][tem.y] >= 1)
      tonext(tem.x, tem.y, 3);
  }
}
int main() {
  cnt = 0;
  scanf("%d%d%d%d%d%d", &n, &m, &r, &c, &x, &y);
  for (int i = 1; i <= n; ++i) scanf("%s", mp[i] + 1);
  for (int i = 0; i <= m; ++i) mp[0][i] = mp[n + 1][i] = '.';
  for (int i = 0; i <= n; ++i) mp[i][0] = mp[i][m + 1] = '.';
  for (int i = 0; i <= n + 1; ++i)
    for (int j = 0; j <= m + 1; ++j) zuo[i][j] = you[i][j] = vis[i][j] = 0;
  zuo[r][c] = x;
  you[r][c] = y;
  bfs(Node(r, c));
  printf("%d\n", cnt);
  return 0;
}
