#include <bits/stdc++.h>
using namespace std;
const int d[4][2] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
int n, m, r, c, x, y, ans = 1;
char g[2005][2005];
bool vis[2005][2005];
deque<pair<pair<int, int>, pair<int, int> > > q;
void BFS() {
  q.push_front(make_pair(make_pair(r, c), make_pair(0, 0)));
  vis[r][c] = true;
  while (!q.empty()) {
    pair<pair<int, int>, pair<int, int> > now = q.front();
    q.pop_front();
    for (int i = 0; i < 4; i++) {
      int tx = now.first.first + d[i][0], ty = now.first.second + d[i][1];
      if (vis[tx][ty]) continue;
      if (tx < 1 || tx > n || ty < 1 || ty > m || g[tx][ty] == '*') continue;
      if (ty == now.first.second) {
        vis[tx][ty] = true;
        q.push_front(make_pair(make_pair(tx, ty), now.second));
      } else {
        if (d[i][1] == -1) {
          if (now.second.first + 1 > x) continue;
          q.push_back(
              make_pair(make_pair(tx, ty),
                        make_pair(now.second.first + 1, now.second.second)));
          vis[tx][ty] = true;
        } else {
          if (now.second.second + 1 > y) continue;
          q.push_back(
              make_pair(make_pair(tx, ty),
                        make_pair(now.second.first, now.second.second + 1)));
          vis[tx][ty] = true;
        }
      }
      ++ans;
    }
  }
  return;
}
int main() {
  scanf("%d %d", &n, &m);
  scanf("%d %d", &r, &c);
  scanf("%d %d", &x, &y);
  for (int i = 1; i <= n; i++) scanf("%s", g[i] + 1);
  if (g[r][c] == '*') return puts("0"), 0;
  BFS();
  printf("%d\n", ans);
  return 0;
}
