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

#define ll long long int
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define MOD 1000000007
#define MAXN   1000001
#define MODA 998244353
#define all(a)      (a).begin(),(a).end()
#define allr(a)      (a).rbegin(),(a).rend()

ll power(ll a,ll b){
    ll result=1;
    while(b>0){
        int lastbit=(b&1);
        if(lastbit){
            result=(result*a);
        }
        a=(a*a);
        b=b>>1;
    }
    return result;
}

ll power2(ll a,ll b,ll p){
    ll result=1;
    while(b>0){
        int lastbit=(b&1);
        if(lastbit){
            result=(result*a)%p;
        }
        a=(a*a)%p;
        b=b>>1;
    }
    return result%p;
}

ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

vector<ll> Sieve(int n){
    bool prime[n+1];
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++){
        if (prime[p] == true){
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    vector<ll>v;
    for (int p=2; p<=n; p++)
        if (prime[p]) v.pb(p);
    return v;
}

vector<ll> SeiveOfEratosthenes(int n){
    vector<ll>v(n+1,0);
    for(int i=0;i<=n;i++){
        v[i]=i;
    }

    for (int p=2; (p*p)<=n; p++){
        if (v[p] == p){
            v[p]=p;
            for (int i=p*p; i<=n; i += p) {
                v[i] = p;
            }
        }
    }
    return v;
}

vector<ll> SmallestPrimeFactors(int n){
    vector<ll>spf(n+1,0);
    spf[1] = 1;
    for (int i=2; i<=n; i++){
        spf[i] = i;
    }
    for (int i=4; i<=n; i+=2){
        spf[i] = 2;
    }
    for (int i=3; (i*i)<=n; i++){
        if (spf[i] == i){
            for (int j=i*i; j<MAXN; j+=i) {
                if (spf[j] == j){
                    spf[j] = i;
                }
            }
        }
    }
    return spf;
}

void shortest(map<int,vector<pair<int,ll>>>m,int src,int n,ll *dist){
    bool visited[n+1];
    set<pair<ll,int>>s;
    for(int i=0;i<=n;i++){
        dist[i]=-1;
        visited[i]=false;
    }

    s.insert(mp(0ll,src));
    dist[src]=0;
    while(!s.empty()){
        auto t=s.begin();
        ll dis=(*t).F;
        int u=(*t).S;
        s.erase(t);
        if(visited[u]){
            continue;
        }
        visited[u]=true;
        for(auto tt:m[u]){
            int v=tt.F;
            ll w=tt.S;
            if(!visited[v]){
                if(dist[v]!=-1 && dist[v]>dis+w){
                    s.erase(mp(dist[v],v));
                    dist[v]=dis+w;
                    s.insert(mp(dist[v],v));
                }else if(dist[v]==-1){
                    dist[v]=dis+w;
                    s.insert(mp(dist[v],v));
                }
            }
        }
    }
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int ttttt=1;
//    cin>>ttttt;
    for(int tttt=1;tttt<=ttttt;tttt++){

        ll n;
        cin>>n;
        string x="";
        while(n>0){
            x+=(n%10+'0');
            n/=10;
        }
        reverse(all(x));
        n=x.size();

        if(n%2){
            ll a[12]={0,0,0,9,0,99,0,999,0,9999,0,99999};
            cout<<a[n];
        }else{
            int t=n/2;
            int j=0;
            ll first=0;
            ll po=t;
            ll second=0;

            while(t<n){
                ll y=power(10ll,po-1);
                first+=((x[j]-'0')*y);
                second+=((x[t]-'0')*y);
                t++;
                j++;
                po--;
            }

            ll ans=first-1;
            if(second>=first){
                ans++;
            }
            cout<<ans;
        }
        cout<<endl;
    }

    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i) = 0; (i) <(n); (i)++) 
#define so(v) sort(v.begin(),v.end())
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
const int MAX = 510000;
const int MOD = 1000000007;
ll gcd(ll a, ll b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long com(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int h,w,x,y;
    cin>>h>>w>>x>>y;
    x--,y--;
    string s[h];
    rep(i,h)cin>>s[i];
    int yoko=0;
    rep(i,w){
        if(s[x][i]=='.')yoko++;
        else{
            if(i>y)break;
            yoko=0;
        }
    }
    int tate=0;
    rep(i,h){
        if(s[i][y]=='.')tate++;
        else{
            if(i>x)break;
            tate=0;
        }
    }
    cout<<tate+yoko-1<<endl;
}