#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int r, c;
  cin >> r >> c;
  int mr, ml;
  cin >> ml >> mr;
  bool g[n][m];
  pair<int, int> d[n][m], no = {-1, -1};
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) {
      g[i][j] = (s[j] == '.');
      d[i][j] = no;
    }
  }
  queue<pair<int, int> > q;
  q.push({--r, --c});
  d[r][c] = {ml, mr};
  int cnt = 0;
  while (!q.empty()) {
    int x = q.front().first, y = q.front().second;
    q.pop();
    if (d[x][y].first > 0 and y > 0 and g[x][y - 1]) {
      if (d[x][y - 1] == no) cnt++;
      bool add = 0;
      if (d[x][y - 1].first < d[x][y].first - 1)
        d[x][y - 1].first = d[x][y].first - 1, add = 1;
      if (d[x][y - 1].second < d[x][y].second)
        d[x][y - 1].second = d[x][y].second, add = 1;
      if (add) q.push({x, y - 1});
    }
    if (d[x][y].second > 0 and y < m - 1 and g[x][y + 1]) {
      if (d[x][y + 1] == no) cnt++;
      bool add = 0;
      if (d[x][y + 1].first < d[x][y].first)
        d[x][y + 1].first = d[x][y].first, add = 1;
      if (d[x][y + 1].second < d[x][y].second - 1)
        d[x][y + 1].second = d[x][y].second - 1, add = 1;
      if (add) q.push({x, y + 1});
    }
    if (x > 0 and g[x - 1][y]) {
      if (d[x - 1][y] == no) cnt++;
      bool add = 0;
      if (d[x - 1][y].first < d[x][y].first)
        d[x - 1][y].first = d[x][y].first, add = 1;
      if (d[x - 1][y].second < d[x][y].second)
        d[x - 1][y].second = d[x][y].second, add = 1;
      if (add) q.push({x - 1, y});
    }
    if (x < n - 1 and g[x + 1][y]) {
      if (d[x + 1][y] == no) cnt++;
      bool add = 0;
      if (d[x + 1][y].first < d[x][y].first)
        d[x + 1][y].first = d[x][y].first, add = 1;
      if (d[x + 1][y].second < d[x][y].second)
        d[x + 1][y].second = d[x][y].second, add = 1;
      if (add) q.push({x + 1, y});
    }
  }
  cout << cnt + 1;
}
