#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
long long fastpower(long long x, long long n, long long M) {
  if (n == 0)
    return 1;
  else if (n % 2 == 0)
    return fastpower((x * x) % M, n / 2, M);
  else
    return (x * fastpower((x * x) % M, (n - 1) / 2, M)) % M;
}
long long negativepow(long long base, long long expo, long long m) {
  if (m == 1) return 0;
  long long ans = 1, y = base % m;
  while (expo > 0) {
    if (expo & 1) ans = ((ans)*y) % m;
    y = (y * y) % m;
    if (y < 0) y += m;
    expo = expo >> 1;
  }
  if (ans < 0) {
    ans = (m - abs(ans) % m);
    return ans;
  }
  return ans % m;
}
long long GCD(long long A, long long B) {
  if (B == 0)
    return A;
  else
    return GCD(B, A % B);
}
bool vowl(char c) {
  return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}
long long modInverse(long long A, long long M) {
  return fastpower(A, M - 2, M);
}
void sieve(long long N) {
  bool isPrime[N + 1];
  for (long long i = 0; i <= N; ++i) {
    isPrime[i] = true;
  }
  isPrime[0] = false;
  isPrime[1] = false;
  for (long long i = 2; i * i <= N; ++i) {
    if (isPrime[i] == true) {
      for (long long j = i * i; j <= N; j += i) isPrime[j] = false;
    }
  }
}
bool isPrime(long long n) {
  if (n <= 1) return 0;
  if (n == 2 || n == 3) return 1;
  if (n % 2 == 0 || n % 3 == 0)
    return 0;
  else {
    for (long long i = 5; i * i <= n; i += 6) {
      if (n % i == 0 || n % (i + 2) == 0) return 0;
    }
    return 1;
  }
}
map<long long, long long> factor(long long n) {
  map<long long, long long> pm;
  long long i;
  for (i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      while (n % i == 0) {
        pm[i]++;
        n = n / i;
      }
    }
  }
  if (n > 1) pm[n]++;
  return pm;
}
void printDivisors(long long n) {
  vector<long long> v;
  for (long long i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        v.push_back(i);
      else {
        v.push_back(i);
        v.push_back(n / i);
      }
    }
  }
}
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  return (a.second < b.second);
}
void print(vector<long long> v) {
  for (auto it : v) cout << it << " ";
  cout << "\n";
}
long long count_one(long long n) {
  long long count = 0;
  while (n) {
    n = n & (n - 1);
    count++;
  }
  return count;
}
long long sz(string s) { return s.length(); }
long long n, m;
bool vis[2004][2004];
long long arr[2004][2004];
long long cnt = 0;
long long cnt1 = 0;
void bfs(long long a, long long b, long long c, long long d) {
  vis[a][b] = true;
  deque<pair<pair<long long, long long>, pair<long long, long long> > > q;
  q.push_front({{a, b}, {c, d}});
  while (!q.empty()) {
    long long x = q.front().first.first;
    long long y = q.front().first.second;
    long long maxl = q.front().second.first;
    long long maxr = q.front().second.second;
    cnt++;
    q.pop_front();
    if (x + 1 < n && arr[x + 1][y] == 1 && vis[x + 1][y] == false) {
      vis[x + 1][y] = true;
      q.push_front({{x + 1, y}, {maxl, maxr}});
    }
    if (x - 1 >= 0 && arr[x - 1][y] == 1 && vis[x - 1][y] == false) {
      vis[x - 1][y] = true;
      q.push_front({{x - 1, y}, {maxl, maxr}});
    }
    if (y + 1 < m && arr[x][y + 1] == 1 && vis[x][y + 1] == false && maxr) {
      maxr;
      vis[x][y + 1] = 1;
      q.push_back({{x, y + 1}, {maxl, maxr - 1}});
    }
    if (y - 1 >= 0 && arr[x][y - 1] && vis[x][y - 1] == false && maxl) {
      maxl;
      vis[x][y - 1] = 1;
      q.push_back({{x, y - 1}, {maxl - 1, maxr}});
    }
  }
}
void bfs1(long long a, long long b, long long c, long long d) {
  vis[a][b] = true;
  queue<pair<pair<long long, long long>, pair<long long, long long> > > q;
  q.push({{a, b}, {c, d}});
  while (!q.empty()) {
    long long x = q.front().first.first;
    long long y = q.front().first.second;
    long long maxl = q.front().second.first;
    long long maxr = q.front().second.second;
    cnt1++;
    q.pop();
    if (x + 1 < n && arr[x + 1][y] == 1 && vis[x + 1][y] == false) {
      vis[x + 1][y] = true;
      q.push({{x + 1, y}, {maxl, maxr}});
    }
    if (x - 1 >= 0 && arr[x - 1][y] == 1 && vis[x - 1][y] == false) {
      vis[x - 1][y] = true;
      q.push({{x - 1, y}, {maxl, maxr}});
    }
    if (y - 1 >= 0 && arr[x][y - 1] && vis[x][y - 1] == false && maxl) {
      maxl;
      vis[x][y - 1] = 1;
      q.push({{x, y - 1}, {maxl - 1, maxr}});
    }
    if (y + 1 < m && arr[x][y + 1] == 1 && vis[x][y + 1] == false && maxr) {
      maxr;
      vis[x][y + 1] = 1;
      q.push({{x, y + 1}, {maxl, maxr - 1}});
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  long long a, b;
  cin >> a >> b;
  a--, b--;
  long long maxl, maxr;
  cin >> maxl >> maxr;
  for (long long i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (long long j = 0; j < m; j++) {
      if (s[j] == '*')
        arr[i][j] = 0;
      else
        arr[i][j] = 1;
    }
  }
  bfs(a, b, maxl, maxr);
  memset(vis, 0, sizeof(vis));
  cout << cnt << "\n";
  return 0;
}
