#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
long long fx[] = {1, -1, 0, 0}, fy[] = {0, 0, 1, -1}, row, col;
long long cell[2005][2005], vis[2005][2005];
vector<pair<long long, long long> > d[2005];
long long res, a, b;
void bfs(long long sx, long long sy) {
  vis[sx][sy] = 1;
  deque<pair<long long, long long> > q;
  q.push_back(make_pair(sx, sy));
  while (!q.empty()) {
    pair<long long, long long> top = q.front();
    q.pop_front();
    for (long long k = 0; k < 4; k++) {
      long long tx = top.first + fx[k], ty = top.second + fy[k];
      if (tx >= 0 && tx < row && ty >= 0 && ty < col && cell[tx][ty] != -1 &&
          vis[tx][ty] == 0) {
        long long hx = d[top.first][top.second].first +
                       (fy[k] == -1 && fx[k] == 0),
                  hy = d[top.first][top.second].second +
                       (fy[k] == 1 && fx[k] == 0);
        if (hx <= a && hy <= b) {
          vis[tx][ty] = 1;
          d[tx][ty].first = hx;
          d[tx][ty].second = hy;
          res++;
          if (fx[k] == 1 || fx[k] == -1)
            q.push_front(make_pair(tx, ty));
          else
            q.push_back(make_pair(tx, ty));
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long tst = 1;
  for (long long tt = 1; tt <= tst; tt++) {
    for (long long i = 0; i < 2005; i++)
      for (long long j = 0; j < 2005; j++) d[i].push_back({0, 0});
    cin >> row >> col;
    long long x, y;
    cin >> x >> y;
    cin >> a >> b;
    char ch;
    for (long long i = 0; i < row; i++)
      for (long long j = 0; j < col; j++) {
        cin >> ch;
        if (ch == '.')
          cell[i][j] = 1;
        else
          cell[i][j] = -1;
      }
    bfs(x - 1, y - 1);
    cout << res + 1 << endl;
  }
  return 0;
}
