#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool f = 1;
  string r = "{";
  for (const auto& x : v) {
    if (!f) r += ", ";
    f = 0;
    r += to_string(x);
  }
  return r + "}";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
vector<string> a;
int n, m;
int r, c, x, y;
bitset<4000000> get(bool bc) {
  vector<vector<pair<int, int>>> d(
      n, vector<pair<int, int>>(m, pair<int, int>(inf, inf)));
  priority_queue<pair<pair<int, int>, pair<int, int>>,
                 vector<pair<pair<int, int>, pair<int, int>>>,
                 greater<pair<pair<int, int>, pair<int, int>>>>
      q;
  q.emplace(pair<int, int>(0, 0), pair<int, int>(r, c));
  d[r][c] = pair<int, int>(0, 0);
  while (!q.empty()) {
    auto it = q.top();
    q.pop();
    int x, y;
    tie(x, y) = it.second;
    if (it.first != d[x][y]) continue;
    for (auto dx = (-1); dx <= (1); ++dx) {
      for (auto dy = (-1); dy <= (1); ++dy) {
        if (abs(dx) + abs(dy) == 1) {
          if (x + dx >= 0 and x + dx <= n - 1 and y + dy >= 0 and
              y + dy <= m - 1 and a[x + dx][y + dy] == '.') {
            pair<int, int> nd = it.first;
            if (dy == -1) (bc ? nd.first : nd.second)++;
            if (dy == 1) (bc ? nd.second : nd.first)++;
            if (nd < d[x + dx][y + dy]) {
              d[x + dx][y + dy] = nd;
              q.emplace(nd, pair<int, int>(x + dx, y + dy));
            }
          }
        }
      }
    }
  }
  bitset<4000000> bt;
  pair<int, int> mc(x, y);
  if (!bc) swap(mc.first, mc.second);
  for (auto i = (0); i <= (n - 1); ++i)
    for (auto j = (0); j <= (m - 1); ++j) {
      if (d[i][j].first <= mc.first and d[i][j].second <= mc.second) {
        bt.set(i * m + j);
      }
    }
  return bt;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  cin >> r >> c;
  cin >> x >> y;
  --r, --c;
  a.resize(n);
  for (auto i = (0); i <= (n - 1); ++i) cin >> a[i];
  cout << (get(0) | get(1)).count() << "\n";
  return 0;
}
