#include<bits/stdc++.h>
using namespace std;
int main(){
    int h,w,x,y;
    cin >> h >> w >> x >> y;
    vector<vector<char>>grid(h,vector<char>(w));
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            cin >> grid[i][j];
        }
    }
    x--;y--;
    int j = x;
    int ans = 0;
    while(j >= 0){
        if(grid[j][y] == '#'){
            break;
        }
        ans ++;
        j--;
    }
    j = x + 1;
    while(j < h){
        if(grid[j][y] == '#'){
            break;
        }
        ans ++;
        j++;
    }
    j = y-1;
    while(j >= 0){
        if(grid[x][j] == '#'){
            break;
        }
        ans ++;
        j--;
    }
    j = y + 1;
    while(j < w){
        if(grid[x][j] == '#'){
            break;
        }
        ans ++;
        j++;
    }
    cout << ans << "\n";
    return 0;
}
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
/*bool ispalindrome(string s)
{
  for(int i=0;i<s.length()/2;i++)
  {
    if(s[i]!=s[s.length()-i-1])
      return false;
  }
  return true;
}//program to get nth ugly no.(having prime factores only 2 3 5)(O(n) time and O(n) space )
ll getNthUglyNo(ll n) {
      // code here
   ll ugly[n];
   ll i2=0;
   ll i3=0;
   ll i5=0;
   ll nm2=2;
   ll nm3=3;
   ll nm5=5;
   ll nxt=1;
   ugly[0]=1;
   for(int i=1;i<n;i++)
   {
       nxt=min(nm2,min(nm3,nm5));
       ugly[i]=nxt;
       if(nxt==nm2)
       {
           i2=i2+1;
           nm2=ugly[i2]*2;
       }
       if(nxt==nm3)
       {
           i3=i3+1;
           nm3=ugly[i3]*3;
       }
       if(nxt==nm5)
       {
           i5+=1;
           nm5=ugly[i5]*5;
       }
   }
    // End of for loop (i=1; i<n; i++)
    return nxt; 
  }
  ll fact(ll n)
  {
    ll res=1;
    for(ll i=2;i<=n;i++)
      res=res*i;
    return res;
  }
  ll ncr(ll n,ll r)
  {
    return fact(n)/(fact(n-r)*fact(r));
  }
  ll convert(ll n,ll k)
  {
    string s="";
    ll temp=0,curr=0;
    while(n>0)
    {
       temp=n%k;
      s+=to_string(temp);
      n/=k;
    }
    reverse(s.begin(),s.end());
    for(ll i=0;i<s.length();i++)
      curr=curr*10+s[i]-'0';
    return curr;
  }
//program to check to whether one string become equal to second after some characters swap or shift
//program to calculate to to check also whether two string are rotation of each other or not*/
 bool areRotations(string str1, string str2)
{
   /* Check if sizes of two strings are same */
   if (str1.length() != str2.length())
        return false;
  
   string temp = str1 + str1; 
  return (temp.find(str2) != string::npos);
  
}
string decimalToBinary(ll n)
{
    //finding the binary form of the number and
    //coneverting it to string.
    string s = bitset<64> (n).to_string();
     
    //Finding the first occurance of "1"
    //to strip off the leading zeroes.
    const auto loc1 = s.find('1');
     
    if(loc1 != string::npos)
        return s.substr(loc1);
     
    return "0";
}
bool issort(pair<string,ll>a,pair<string,ll>b)
{
  return a.second>b.second;
}
  void solve()
  { 
   ll n,i;
   cin>>n;
   string s[n];
   ll a[n+1];
   vector<pair<string,ll>>v;
   for(i=0;i<n;i++)
   {
    cin>>s[i]>>a[i];
    v.push_back(make_pair(s[i],a[i]));
   }
   sort(v.begin(),v.end(),issort);
   cout<<v[1].first<<endl;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
   // ll t;
    //cin>>t;
    //while(t--)
   solve();
  return 0;
}