#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007ll;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= MOD;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
  }
  return res;
}
template <typename t1, typename t2>
inline bool upmax(t1 &a, t2 b) {
  if (a < (t1)b) {
    a = (t1)b;
    return true;
  } else
    return false;
}
template <typename t1, typename t2>
inline bool upmin(t1 &a, t2 b) {
  if (a > (t1)b) {
    a = (t1)b;
    return true;
  } else
    return false;
}
template <typename T>
inline T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
inline T lcm(T a, T b) {
  return a * (b / gcd(a, b));
}
template <typename T>
inline T sqr(T a) {
  return a * a;
}
int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int INF = 1000000404;
const long long LINF = 4000000000000000404ll;
const long double PI = acos(-1.0);
const long double EPS = 1e-9;
int SQ = 318;
int timer = 0;
const int N = 2200;
int d1[N][N];
int d2[N][N];
bool a[N][N];
bool res[N][N];
void solve() {
  int n, m;
  cin >> n >> m;
  int r, c;
  cin >> r >> c;
  int x, y;
  cin >> x >> y;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char ch;
      cin >> ch;
      if (ch == '.')
        a[i][j] = 1;
      else
        a[i][j] = 0;
    }
  }
  queue<int> qx;
  queue<int> qy;
  qx.push(r);
  qy.push(c);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      d1[i][j] = d2[i][j] = INF;
    }
  }
  d1[r][c] = 0;
  d2[r][c] = 0;
  while (!qx.empty()) {
    int i = qx.front();
    qx.pop();
    int j = qy.front();
    qy.pop();
    int w = d1[i][j];
    int w2 = d2[i][j];
    for (int d = 0; d < 4; d++) {
      int X = i + dx[d];
      int Y = j + dy[d];
      int right = 0, left = 0;
      if (dy[d] != 0) {
        if (dy[d] == -1)
          left = 1;
        else
          right = 1;
      }
      if (a[X][Y] && d1[X][Y] >= w + right) {
        if (d1[X][Y] > w + right) {
          d1[X][Y] = w + right;
          d2[X][Y] = w2 + left;
          qx.push(X);
          qy.push(Y);
        } else {
          if (d2[X][Y] > w2 + left) {
            d2[X][Y] = w2 + left;
            qx.push(X);
            qy.push(Y);
          }
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] && d1[i][j] <= y && d2[i][j] <= x) {
        res[i][j] = true;
      }
      d1[i][j] = d2[i][j] = INF;
    }
  }
  d1[r][c] = 0;
  d2[r][c] = 0;
  qx.push(r);
  qy.push(c);
  while (!qx.empty()) {
    int i = qx.front();
    qx.pop();
    int j = qy.front();
    qy.pop();
    int w = d1[i][j];
    int w2 = d2[i][j];
    for (int d = 0; d < 4; d++) {
      int X = i + dx[d];
      int Y = j + dy[d];
      int right = 0, left = 0;
      if (dy[d] != 0) {
        if (dy[d] == -1)
          left = 1;
        else
          right = 1;
      }
      if (a[X][Y] && d1[X][Y] >= w + left) {
        if (d1[X][Y] > w + left) {
          d1[X][Y] = w + left;
          d2[X][Y] = w2 + right;
          qx.push(X);
          qy.push(Y);
        } else {
          if (d2[X][Y] > w2 + right) {
            d2[X][Y] = w2 + right;
            qx.push(X);
            qy.push(Y);
          }
        }
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] && d1[i][j] <= x && d2[i][j] <= y) {
        res[i][j] = true;
      }
      if (res[i][j]) ans++;
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
