#include <bits/stdc++.h>
using namespace std;
void PT(long long a);
void PT1(long long a);
const long long M = 2010, mod = 1e9 + 7;
long long n, m, x, y, a, b, dp[M][M], mp[M][M], mp1[M][M];
vector<string> v;
void bfs(long long r, long long c, long long l, long long ri) {
  queue<pair<long long, long long>> q;
  q.push({r, c});
  mp[r][c] = l;
  mp1[r][c] = ri;
  while (!q.empty()) {
    r = (q.front()).first;
    c = (q.front()).second;
    q.pop();
    l = mp[r][c];
    ri = mp1[r][c];
    if (l <= a && ri <= b) dp[r][c] = 1;
    if (c - 1 >= 0 && v[r][c - 1] != '*') {
      if (l + 1 <= a && ri <= b &&
          (mp[r][c - 1] > l + 1 || mp1[r][c - 1] > ri)) {
        q.push({r, c - 1});
        mp[r][c - 1] = l + 1;
        mp1[r][c - 1] = ri;
      }
    }
    if (c + 1 < m && v[r][c + 1] != '*') {
      if (l <= a && ri + 1 <= b &&
          (mp[r][c + 1] > l || mp1[r][c + 1] > ri + 1)) {
        q.push({r, c + 1});
        mp[r][c + 1] = l;
        mp1[r][c + 1] = ri + 1;
      }
    }
    if (r - 1 >= 0 && v[r - 1][c] != '*') {
      if (l <= a && ri <= b && (mp[r - 1][c] > l || mp1[r - 1][c] > ri)) {
        q.push({r - 1, c});
        mp[r - 1][c] = l;
        mp1[r - 1][c] = ri;
      }
    }
    if (r + 1 < n && v[r + 1][c] != '*') {
      if (l <= a && ri <= b && (mp[r + 1][c] > l || mp1[r + 1][c] > ri)) {
        q.push({r + 1, c});
        mp[r + 1][c] = l;
        mp1[r + 1][c] = ri;
      }
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  {
    cin >> n >> m >> x >> y >> a >> b;
    for (long long i = 0; i < n; i++) {
      string s;
      cin >> s;
      v.push_back(s);
    }
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) {
        mp[i][j] = INT_MAX;
        mp1[i][j] = INT_MAX;
      }
    }
    bfs(x - 1, y - 1, 0, 0);
    long long ans = 0;
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j < m; j++) {
        if (dp[i][j] == 1) ans++;
      }
    }
    cout << ans;
  }
  return 0;
}
void PT(long long a) { cout << a << "\n"; }
void PT1(long long a) { cout << a << " "; }
