#include <bits/stdc++.h>
using namespace std;
const int N = 2005 + 10;
char s[N][N];
pair<int, int> dist[N][N];
int inf = N * N;
int n, m;
int bfs(int r, int c, int x_limit, int y_limit) {
  int res = 0;
  dist[r][c] = {0, 0};
  deque<pair<int, int> > q;
  q.push_back({r, c});
  while (!q.empty()) {
    int x = q.front().first;
    int y = q.front().second;
    q.pop_front();
    if (dist[x][y].first <= x_limit && dist[x][y].second <= y_limit) res++;
    if (x > 0 && s[x - 1][y] != '*' && dist[x - 1][y] == make_pair(inf, inf)) {
      dist[x - 1][y] = dist[x][y];
      q.push_front({x - 1, y});
    }
    if (x + 1 < n && s[x + 1][y] != '*' &&
        dist[x + 1][y] == make_pair(inf, inf)) {
      dist[x + 1][y] = dist[x][y];
      q.push_front({x + 1, y});
    }
    if (y > 0 && s[x][y - 1] != '*' && dist[x][y - 1] == make_pair(inf, inf)) {
      dist[x][y - 1] = dist[x][y];
      dist[x][y - 1].first++;
      q.push_back({x, y - 1});
    }
    if (y + 1 < m && s[x][y + 1] != '*' &&
        dist[x][y + 1] == make_pair(inf, inf)) {
      dist[x][y + 1] = dist[x][y];
      dist[x][y + 1].second++;
      q.push_back({x, y + 1});
    }
  }
  return res;
}
int main() {
  scanf("%d %d", &n, &m);
  int r, c;
  scanf("%d %d", &r, &c);
  r--, c--;
  int x, y;
  scanf("%d %d", &x, &y);
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) dist[i][j] = {inf, inf};
  int res = bfs(r, c, x, y);
  printf("%d\n", res);
}
