#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
vector<string> mp;
int n, m;
int st, ed;
int lmax, rmax;
int ans;
set<pair<int, int>> pp;
vector<pair<int, int>> pos, vis[2010];
struct node {
  int x, y;
  int l, r;
  node(int a, int b, int c, int d) {
    x = a;
    y = b;
    l = c;
    r = d;
  }
};
void bfs(int x, int y) {
  queue<node> que;
  while (!que.empty()) que.pop();
  node nd(x, y, 0, 0);
  pp.insert(make_pair(x, y));
  que.push(nd);
  int nx, ny, nl, nr;
  while (!que.empty()) {
    node noww = que.front();
    que.pop();
    nx = noww.x;
    ny = noww.y;
    for (int i = 0; i < 4; ++i) {
      nx = noww.x + pos[i].first;
      ny = noww.y + pos[i].second;
      nl = noww.l;
      nr = noww.r;
      if (i == 0) nl += 1;
      if (i == 1) nr += 1;
      if ((nx < 0 || nx >= n) || (ny < 0 || ny >= m) || nl > lmax ||
          nr > rmax) {
        continue;
      }
      if (mp[nx][ny] == '*') continue;
      node ndd(nx, ny, nl, nr);
      if (nl < vis[nx][ny].first || nr < vis[nx][ny].second) {
        vis[nx][ny].first = nl;
        vis[nx][ny].second = nr;
        que.push(ndd);
        pp.insert(make_pair(nx, ny));
      }
    }
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  while (cin >> n >> m) {
    cin >> st >> ed;
    cin >> lmax >> rmax;
    string line;
    mp.clear();
    pp.clear();
    ans = 0;
    for (int i = 0; i < n; ++i) {
      cin >> line;
      mp.push_back(line);
      vis[i].clear();
      for (int j = 0; j < m; ++j)
        vis[i].push_back(make_pair(lmax + 1, rmax + 1));
    }
    pos.clear();
    pos.push_back(make_pair(0, -1));
    pos.push_back(make_pair(0, 1));
    pos.push_back(make_pair(1, 0));
    pos.push_back(make_pair(-1, 0));
    bfs(st - 1, ed - 1);
    set<pair<int, int>>::iterator p;
    cout << pp.size() << endl;
  }
  return 0;
}
