#include <bits/stdc++.h>

#define numm ch-48
#define pd putchar(' ')
#define pn putchar('\n')
#define int long long int
using namespace std;

template<typename T>
void read(T &res) {
    bool flag = false;
    char ch;
    while (!isdigit(ch = getchar())) (ch == '-') && (flag = true);
    for (res = numm; isdigit(ch = getchar()); res = (res << 1) + (res << 3) + numm);
    flag && (res = -res);
}

template<typename T>
void write(T x) {
    if (x < 0) putchar('-'), x = -x;
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}

/// #pragma GCC optimize(3,"Ofast","inline")
//////////////////////////////////////////////////////////////////////////////////////////////

int h, w, x, y;
string mp[105];

signed main() {
    cin >> h >> w >> x >> y;
    for (int i = 1; i <= h; i++) {
        cin >> mp[i];
        mp[i] = ' ' + mp[i];
    }
    int ans = 1;
    if (mp[x][y] != '.') {
        write(0), pn;
    }
    int i = 1;
    while (x + i <= h and mp[x + i][y] == '.') ans++, i++;
    i = 1;
    while (x - i > 0 and mp[x - i][y] == '.') ans++, i++;
    i = 1;
    while (y + i <= w and mp[x][y + i] == '.') ans++, i++;
    i = 1;
    while (y - i > 0 and mp[x][y - i] == '.') ans++, i++;
    write(ans);
    return 0;
}


#include <bits/stdc++.h>
#include <iostream>
#include<stdio.h>
#include<math.h>
#include<string.h>
using namespace std;
double mina(double a,double b)
{
    if(a<=b)
    return a;
    return b;
}
double maxa(double a,double b)
{
    if(a<=b)
    return b;
    return a;
}



int main() {
   long long int t,n,i,j,k,l,flag,flag1,count,count1,count2,count3,count4,sum,max1,max2,m,c1,c2,temp,suma,sumb;
  long long int d,e,a,b,c;
  
  double a2[300001],b1[2002][3],a1[300001];

 
        //vector< long long int> v1,v2,v;
        //  vector< pair <long long int,long long int> > v3; 
  //  string s1,s2,s;
//  char s[300001],s1[300001];
  //  long long int f[100001];
  //   for(i=0;i<100001;i++)
  //    f[i]=0;
    count=0,flag=0,flag1=0,sum=0,max1=0,max2=0,c1=0,c2=0,temp=0,suma=0,sumb=0,count1=0,count2=0,count3=0,count4=0;
  // long long int max3=0,max4=0,ans=0,mina=999999999999999999,c0=0,c3,c4;
   cin>>n;
   for(i=0;i<n;i++)
   {
       for(j=0;j<3;j++)
       cin>>b1[i][j];
   }
   for(i=0;i<n;i++)
   {
       if(b1[i][0]==2)
       b1[i][2]=b1[i][2]-0.1;
      else  if(b1[i][0]==3)
       b1[i][1]=b1[i][1]+0.1;
        if(b1[i][0]==4)
        {
       b1[i][2]=b1[i][2]-0.1;
       b1[i][1]=b1[i][1]+0.1;
        }
       
   }
   
   for(i=0;i<n;i++)
   {
       if(b1[i][1]>b1[i][2])
       swap(b1[i][1],b1[i][2]);
   }
   for(i=0;i<n;i++)
   {
       for(j=i+1;j<n;j++)
       {
           if(mina(b1[i][2],b1[j][2]) >=maxa( b1[i][1],b1[j][1]) )
           count++;
          
       }
   }
   //for(i=0;i<n;i++)
  // for(j=0;j<3;j++)
  // cout<<b1[i][j];
   cout<<count;
	return 0;
}