//Bulbul khan-420...
#include <bits/stdc++.h>
#include <cstring>
#define ll long long int
#define pb() push_back()
#define f(i,n) for(i=0;i<n;i++)
using namespace std;
int main()
{
      ll t,a,b,c,d,i,j,k,l,n,m,x,y,z;
      cin>>n>>m>>x>>y;
     string s[n+6];
     for(i=0;i<n;i++)
       cin>>s[i];
     x--;
     y--;
     j=0;
    if(s[x][y]=='#')
       j=0;
    else{
       for(i=y+1;i<m;i++){
        if(s[x][i]=='.')
           j++;
         else
           break;
}
     for(i=y-1;i>=0;i--){
        if(s[x][i]=='.')
           j++;
       else
         break;
}
      for(i=x+1;i<n;i++){
       if(s[i][y]=='.')
         j++;
      else
       break;
}
     for(i=x-1;i>=0;i--){
        if(s[i][y]=='.')
          j++;
        else
         break;
}
      j++;
}
     cout<<j;
}
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int main(){
  long long x, y, a, b;
  cin >> x >> y >> a >> b;

  long long ans = 0;
  while((long double)a * x <= 9e18 and a * x <= b + x and a * x < y){
    x *= a;
    ans++;
  }

  long long diff = (y - x - 1)/b;
  if(diff > 0ll) ans += diff;

  cout << ans << endl;
  return 0;
}