
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n;
    double x, y;
    complex<double> a, b;

    cin >> n;
    cin >> x >> y;
    a = {x, y};
    cin >> x >> y;
    b = {x, y};

    auto m = (a + b) / 2.0;

    auto res = m + (a - m) * polar(1.0, M_PI * 2.0 / n);

    cout << setprecision(9) << res.real() << " " << res.imag() << endl;
}

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
#define check(x) if(x>=mod) x-=mod
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
void chmax(int &x,int y){if(x < y) x = y;}
void chmin(int &x,int y){if(x > y) x = y;}
int qpow(int x,int y){
    int ret = 1;
    while(y) {
        if(y & 1) ret = (ll)ret * x % mod;
        x = (ll)x * x % mod;
        y >>= 1;
    }
    return ret;
}
int n,m,a,b,ans;
char s[1005][1005];
int main()
{
    scanf("%d%d%d%d",&n,&m,&a,&b);
    rep(i,1,n) scanf("%s",s[i]+1);
    int P = a;
    while(P > 1 && s[P - 1][b] == '.') ans++,P--;
    P = b;
    while(P > 1 && s[a][P - 1] == '.') ans++,P--;
    P = a;
    while(P < n && s[P + 1][b] == '.') ans++,P++;
    P = b;
    while(P < m && s[a][P + 1] == '.') ans++,P++;
    printf("%d\n",ans+1);
    return 0;
}