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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    if(a == 0) return 0;
    b %= (M - 1);  //M must be prime here
    
    int res = 1;
    
    while(b > 0)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}

unordered_map<int,int> mp;

void solve()
{
    int n,m;
    cin >> n >> m;
    
    pii a[m];
    f(i,m) cin >> a[i].F >> a[i].S;
    sort(a,a+m);
    
    mp[n] = 1;
   
    int ptr = 0;
    int cur_row = 0;
    
    while(ptr < m)
    {
        cur_row = a[ptr].F;
        
        unordered_map<int,int> prev_data;
        vector<int> upd;
        
        while(ptr < m && a[ptr].F == cur_row)
        {
            upd.pb(a[ptr].S);
            ptr++;
        }
        
        for(auto x : upd)
        {
            prev_data[x - 1] = mp[x - 1];
            prev_data[x] = mp[x];
            prev_data[x + 1] = mp[x + 1];
        }
            
        for(auto x : upd)
        {
            mp[x] = (prev_data[x-1] || prev_data[x+1]);
        }
    }
    
    int res = 0;
    for(auto x : mp) res += x.S;
    cout << res;
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define int long long
#define eb emplace_back
#define maxll (1ll<<62)
#define minll -(1ll<<62)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define show(X) for(auto aa:X)cout<<aa<<' ';cout<<'\n';
//const double PI=3.1415926535898;
//const int mod=1000000007;
/**********************************************************************/

int32_t main()
{	ios_base::sync_with_stdio(false);
	cin.tie(NULL);//cout << setprecision(15);

	int h, w, x, y;
	cin >> h >> w >> x >> y;
	vector<string> v(h);
	rep(i, 0, h)
	{
		cin >> v[i];
	}
	int cnt = 0;
	if (v[x - 1][y - 1] == '.')
		cnt++;
	int i;
	for (i = x - 2; i >= 0; i--)
	{
		if (v[i][y - 1] == '#')
			break;
		cnt++;
	}
	for (i = x; i < h; i++)
	{
		if (v[i][y - 1] == '#')
			break;
		cnt++;
	}
	for (i = y - 2; i >= 0; i--)
	{
		if (v[x - 1][i] == '#')
			break;
		cnt++;
	}
	for (i = y; i < w; i++)
	{
		if (v[x - 1][i] == '#')
			break;
		cnt++;
	}
	cout << cnt;


	return 0;
}