#include <bits/stdc++.h>
using namespace std;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
string s[300000];
bool vis[3000][3000];
void bfs(int r, int c, int remX, int remY) {
  vis[r][c] = true;
  deque<pair<pair<int, int>, pair<int, int> > > q;
  q.push_back({{r, c}, {remX, remY}});
  while (!q.empty()) {
    pair<pair<int, int>, pair<int, int> > F = q.front();
    int x = F.first.first;
    int y = F.first.second;
    int rX = F.second.first;
    int rY = F.second.second;
    s[x][y] = '+';
    q.pop_front();
    for (int i = 0; i <= 3; i++) {
      if (i == 1 && rX <= 0) continue;
      if (i == 0 && rY <= 0) continue;
      int newX = x + dx[i];
      int newY = y + dy[i];
      if (vis[newX][newY] == false && s[newX][newY] == '.') {
        vis[newX][newY] = true;
        if (i == 1)
          q.push_back({{newX, newY}, {rX - 1, rY}});
        else if (i == 0)
          q.push_back({{newX, newY}, {rX, rY - 1}});
        else
          q.push_front({{newX, newY}, {rX, rY}});
      }
    }
  }
}
int main() {
  memset(vis, false, sizeof vis);
  int n, m;
  cin >> n >> m;
  int R, C;
  cin >> R >> C;
  int x, y;
  cin >> x >> y;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    s[i] = "*" + s[i] + "*";
  }
  for (int i = 0; i <= m + 10; i++) {
    s[0].push_back('*');
    s[n + 1].push_back('*');
  }
  bfs(R, C, x, y);
  int counter = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (vis[i][j] == true) counter++;
    }
  }
  cout << counter << endl;
}
