#include<iostream>
#include<cstdio>
#include<string>
#include<queue>
using namespace std;
typedef struct node
{
int x;
int y;
}Node;
int map[101][101];//标记气球颜色
int mark[101][101];//
int h,w,bi,bj,temp;
int mark2[101][101],sum2;
int dic[6][2];
void fun(int n)
{
if(n % 2 == 1)
{
dic[0][0] = -1; dic[0][1] = 0;
dic[1][0] = 1; dic[1][1] = 0;
dic[2][0] = 0; dic[2][1] = -1;
dic[3][0] = 0; dic[3][1] = 1;
dic[4][0] = -1; dic[4][1] = -1;
dic[5][0] = 1; dic[5][1] = -1;//六个方向,上下左右,左下,左上
}
else
{
dic[0][0] = -1; dic[0][1] = 0;
dic[1][0] = 1; dic[1][1] = 0;
dic[2][0] = 0; dic[2][1] = -1;
dic[3][0] = 0; dic[3][1] = 1;
dic[4][0] = -1; dic[4][1] = 1;
dic[5][0] = 1; dic[5][1] = 1;//六个方向右上,右下
}
}
void Bfs2(int x,int y)//广搜与最上层相连的气球
{
int k;
queue<Node> Q;
Node q,p;
p.x = x;
p.y = y;
Q.push(p);
mark2[x][y] = 1;
sum2++;
while(!Q.empty())
{
q = Q.front();
Q.pop();
fun(q.x);
for(k = 0;k < 6;k++)
{
p.x = q.x + dic[k][0];
p.y = q.y + dic[k][1];
if(p.x>0 && p.x<=h && p.y>0 && p.y<=w && mark2[p.x][p.y]==0 && mark[p.x][p.y]==0)
{
mark2[p.x][p.y] = 1;
sum2++;
Q.push(p);
}
}
}
}
void Bfs()//广搜可以直接爆炸的气球
{
int k,sum;
queue<Node> Q;
Node p,q;
p.x = bi;
p.y = bj;
Q.push(p);
mark[bi][bj] = 1;
sum = 1;
while(!Q.empty())
{
q = Q.front();
Q.pop();
fun(q.x);
for(k = 0;k < 6;k++)
{
p.x = q.x + dic[k][0];
p.y = q.y + dic[k][1];
if(p.x > 0 && p.x <= h && p.y > 0 && p.y <= w && mark[p.x][p.y] == 0 && map[p.x][p.y] == map[bi][bj])
{
mark[p.x][p.y] = 1;
sum++;
Q.push(p);
}
}
}
if(sum >= 3)
{
sum2 = 0;//记录与最上层相连的气球数
for(k = 1; k <= w;k++)
{
if(mark[1][k] == 0 && mark2[1][k] == 0)
Bfs2(1,k);
}
sum = temp - sum2;
}
else
sum = 0;
cout<<sum<<endl;
}
int main()
{
while(scanf("%d%d%d%d",&h,&w,&bi,&bj) != EOF)
{
int i,j;
string str;
for(i = 1;i <= h;i++)
{
for(j = 1;j <= w;j++)
{
map[i][j] = 0;
mark[i][j] = 1;//表示没有气球
mark2[i][j] = 0;//未被访问过
}
}
temp = 0;//记录总的气球数
for(i = 1;i <= h;i++)
{
cin>>str;
if(i%2 ==0)
str += " ";
for(j = 0;j < str.length();j++)
{
if(str[j] >='a' && str[j] <= 'z')
{
map[i][j+1] = str[j]-'a'+1;//标记球的颜色
mark[i][j+1] = 0;
temp++;
}
}
}
if(mark[bi][bj] == 1)
{
cout<<"0"<<endl;
continue;
}
Bfs();
}
return 0;
}