#include "bits/stdc++.h"
#define rep0(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define rep1(var,cnt) for(int (var)=1; (var)<(int)(cnt); ++(var))
#define repi(var,init,cnt) for(int (var)=(init); (var)<(int)(cnt); ++(var))
#define Yn(flag) cout<<(flag?"Yes":"No")
#define pre(var) cout<<fixed<<setprecision(var);
using namespace std;

using ll = long long;
using ull = unsigned long long;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<" ";
  }
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
    for(T &in:v) is>>in;
    return is;
}

template<typename T>
T chclamp(T x, T low, T high){
  if(x<low) return low;
  if(x>high) return high;
  return x;
}

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

void MAIN(void);

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(0);
  //pre(10);
  MAIN();
}
// Usual Template End =========================================
// Template End ===============================================
ll INF=numeric_limits<ll>::max()/4;
constexpr int MOD=1e9+7;
using mint = ModInt<MOD>;

#define between(a,b,c) ((a)<=(b))&&((b)<(c))

void MAIN(void){
  int H,W,X,Y; cin>>H>>W>>X>>Y;
  vec<string> S(H); cin>>S;
  --X,--Y;
  int ans=1;
  int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
  for(int i=0; i<4; ++i){
    int x=X,y=Y;
    while(1){
      x+=dx[i],y+=dy[i];
      //cout<<x<<y<<endl;
      if(!(between(0,x,H)&&between(0,y,W))) break;
      else if(S[x][y]=='.') ++ans;
      else break;
    }
  }
  cout<<ans<<endl;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); i++)
#define rep2(i,n) for (int i=1; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int main() {
  int a,b,x,y; cin >> a >> b >> x >> y;
  int fast = min(y,2*x);
  int dist = abs((2*b+1)-(2*a));
  int ans = (dist/2)*fast+x;
  cout << ans << endl;
}