#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long int n, m;
  cin >> n >> m;
  long long int str, stc;
  cin >> str >> stc;
  long long int x, y;
  cin >> x >> y;
  vector<vector<long long int>> yes(n + 1, vector<long long int>(m + 1, 0)),
      dp1(n + 1, vector<long long int>(m + 1, -1)), dp2;
  dp2 = dp1;
  yes[str][stc]++;
  dp1[str][stc] = x;
  dp2[str][stc] = y;
  vector<string> a(n + 1);
  for (long long int i = 1; i <= n; i++) {
    string temp;
    cin >> temp;
    temp = '*' + temp;
    a[i] = temp;
  }
  deque<pair<long long int, long long int>> q, left;
  q.push_back({str, stc});
  left.push_back({x, y});
  while (1) {
    if (q.empty()) break;
    pair<long long int, long long int> point = q.front(), l = left.front();
    if (point.first > 1 && a[point.first - 1][point.second] == '.') {
      if (dp1[point.first - 1][point.second] < l.first ||
          dp2[point.first - 1][point.second] < l.second) {
        q.push_back({point.first - 1, point.second});
        left.push_back(left.front());
        yes[point.first - 1][point.second]++;
        dp1[point.first - 1][point.second] = l.first;
        dp2[point.first - 1][point.second] = l.second;
      }
    }
    if (point.first < n && a[point.first + 1][point.second] == '.') {
      if (dp1[point.first + 1][point.second] < l.first ||
          dp2[point.first + 1][point.second] < l.second) {
        q.push_back({point.first + 1, point.second});
        left.push_back(left.front());
        yes[point.first + 1][point.second]++;
        dp1[point.first + 1][point.second] = l.first;
        dp2[point.first + 1][point.second] = l.second;
      }
    }
    if (point.second > 1 && a[point.first][point.second - 1] == '.' &&
        l.first != 0) {
      if (dp1[point.first][point.second - 1] < l.first - 1 ||
          dp2[point.first][point.second - 1] < l.second) {
        q.push_back({point.first, point.second - 1});
        left.push_back({l.first - 1, l.second});
        yes[point.first][point.second - 1]++;
        dp1[point.first][point.second - 1] = l.first - 1;
        dp2[point.first][point.second - 1] = l.second;
      }
    }
    if (point.second < m &&
        a[point.first][point.second + 1] == '.' & l.second != 0) {
      if (dp1[point.first][point.second + 1] < l.first ||
          dp2[point.first][point.second + 1] < l.second - 1) {
        q.push_back({point.first, point.second + 1});
        left.push_back({l.first, l.second - 1});
        yes[point.first][point.second + 1]++;
        dp1[point.first][point.second + 1] = l.first;
        dp2[point.first][point.second + 1] = l.second - 1;
      }
    }
    q.pop_front();
    left.pop_front();
  }
  long long int ans = 0;
  for (long long int i = 1; i <= n; i++) {
    for (long long int j = 1; j <= m; j++) {
      if (yes[i][j]) {
        ans++;
      }
    }
  }
  cout << ans;
}
