#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
std::pair<T, U> operator+(const std::pair<T, U>& l, const std::pair<T, U>& r) {
  return {l.first + r.first, l.second + r.second};
}
const long long INF64 = 1e18;
const long long INF32 = 1e9;
char graph[2002][2002];
long long maxX[2002][2002];
struct Pos {
  long long r, c, x, y;
  Pos() {}
  Pos(long long _r, long long _c, long long _x, long long _y)
      : r(_r), c(_c), x(_x), y(_y) {}
  Pos operator+(Pos other) {
    return Pos(r + other.r, c + other.c, x + other.x, y + other.y);
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie();
  if (false) {
    freopen("D.in", "r", stdin);
    cerr << "Remember to switch INPUT_FILE off before submitting!" << endl
         << endl;
    freopen("D.out", "w", stdout);
  }
  {
    long long n, m, r, c, x, y;
    cin >> n >> m >> r >> c >> x >> y;
    for (long long i = (1); i <= (n); i++) {
      for (long long j = (1); j <= (m); j++) {
        cin >> graph[i][j];
      }
    }
    Pos moves[4] = {Pos(0, 1, 0, -1), Pos(0, -1, -1, 0), Pos(1, 0, 0, 0),
                    Pos(-1, 0, 0, 0)};
    Pos pos(r, c, x, y);
    list<Pos> queue;
    queue.push_back(pos);
    graph[r][c] = '+';
    maxX[r][c] = x;
    Pos p;
    long long cnt = 1;
    while (!queue.empty()) {
      pos = queue.front();
      queue.pop_front();
      if (false) {
        for (long long i = (1); i <= (n); i++) {
          for (long long j = (1); j <= (m); j++) {
            cerr << graph[i][j];
          }
          cerr << endl;
        }
        cerr << pos.r << ' ' << pos.c << ' ' << pos.x << ' ' << pos.y << endl;
        cerr << endl;
      }
      for (long long i = (0); i < (4); i++) {
        p = pos + moves[i];
        if (p.r >= 1 && p.r <= n && p.c >= 1 && p.c <= m && p.x >= 0 &&
            p.y >= 0 && graph[p.r][p.c] != '*') {
          if (graph[p.r][p.c] == '.') {
            queue.push_back(p);
            graph[p.r][p.c] = '+';
            cnt++;
            maxX[p.r][p.c] = p.x;
          } else if (maxX[p.r][p.c] < p.x) {
            queue.push_front(p);
            maxX[p.r][p.c] = p.x;
          }
        }
      }
    }
    if (false) {
      for (long long i = (1); i <= (n); i++) {
        for (long long j = (1); j <= (m); j++) {
          cerr << graph[i][j];
        }
        cerr << endl;
      }
    }
    cout << cnt << endl;
  }
  if (false) {
    system("gnome-open D.in");
    system("gnome-open D.correct");
    system("gnome-open D.out");
    fstream myAns("D.out");
    fstream correctAns("D.correct");
    string myLine, correctLine;
    long long lineIndex = 1;
    bool moreMyAns, moreCorrectAns;
    moreMyAns = (bool)getline(myAns, myLine);
    moreCorrectAns = (bool)getline(correctAns, correctLine);
    while (moreMyAns && moreCorrectAns) {
      cerr << lineIndex++ << "\t" << (myLine == correctLine ? "ok" : "WRONG")
           << endl;
      moreMyAns = (bool)getline(myAns, myLine);
      moreCorrectAns = (bool)getline(correctAns, correctLine);
    }
    if (moreMyAns) {
      cerr << "ERROR: My answer is too long! Excessive lines:" << endl;
      do {
        cerr << lineIndex++ << "\t" << myLine << endl;
      } while (getline(myAns, myLine));
    } else if (moreCorrectAns) {
      cerr << "ERROR: My answer is too short! Missing lines:" << endl;
      do {
        cerr << lineIndex++ << "\t" << correctLine << endl;
      } while (getline(correctAns, correctLine));
    }
    myAns.flush();
    myAns.close();
    correctAns.flush();
    correctAns.close();
  }
  return 0;
}
