#include <bits/stdc++.h>
using namespace std;
int n, m;
int sy, sx;
int x, y;
pair<int, int> maxCombs[2300][2300][3];
char field[2300][2300];
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, 1, -1};
pair<int, int> costs[] = {{-1, 0}, {0, -1}, {0, 0}, {0, 0}};
void calc() {
  queue<vector<int> > q;
  q.push({sy - 1, sx - 1, x, y});
  while (q.size()) {
    vector<int> curr = q.front();
    q.pop();
    int currY = curr[0], currX = curr[1], leftLeft = curr[2],
        rightLeft = curr[3];
    if (maxCombs[currY][currX][0].first > leftLeft &&
        maxCombs[currY][currX][1].second > rightLeft &&
        maxCombs[currY][currX][2].first > leftLeft &&
        maxCombs[currY][currX][2].second > rightLeft) {
      continue;
    }
    for (int i = 0; i < 4; i++) {
      if (currY + dy[i] < 0 || currY + dy[i] >= n || currX + dx[i] < 0 ||
          currX + dx[i] >= m || field[currY + dy[i]][currX + dx[i]] == '*' ||
          leftLeft + costs[i].first < 0 || rightLeft + costs[i].second < 0)
        continue;
      bool taken = false;
      if (maxCombs[currY + dy[i]][currX + dx[i]][0].first <
          leftLeft + costs[i].first) {
        maxCombs[currY + dy[i]][currX + dx[i]][0].first =
            leftLeft + costs[i].first;
        q.push({currY + dy[i], currX + dx[i], leftLeft + costs[i].first,
                rightLeft + costs[i].second});
        taken = true;
      }
      if (maxCombs[currY + dy[i]][currX + dx[i]][1].second <
          rightLeft + costs[i].second) {
        maxCombs[currY + dy[i]][currX + dx[i]][1].second =
            rightLeft + costs[i].second;
        if (!taken)
          q.push({currY + dy[i], currX + dx[i], leftLeft + costs[i].first,
                  rightLeft + costs[i].second});
        taken = true;
      }
      if (maxCombs[currY + dy[i]][currX + dx[i]][2].second <
              rightLeft + costs[i].second &&
          maxCombs[currY + dy[i]][currX + dx[i]][2].first <
              leftLeft + costs[i].first) {
        maxCombs[currY + dy[i]][currX + dx[i]][2].first =
            leftLeft + costs[i].first;
        maxCombs[currY + dy[i]][currX + dx[i]][2].second =
            rightLeft + costs[i].second;
        if (!taken)
          q.push({currY + dy[i], currX + dx[i], leftLeft + costs[i].first,
                  rightLeft + costs[i].second});
        taken = true;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (maxCombs[i][j][0].first != -1)
        ans++;
      else if (i == sy - 1 and j == sx - 1)
        ans++;
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> sy >> sx >> x >> y;
  for (int i = 0; i < 2300; i++) {
    for (int j = 0; j < 2300; j++) {
      for (int k = 0; k < 3; k++) maxCombs[i][j][k] = {-1, -1};
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> field[i][j];
    }
  }
  calc();
  return 0;
}
