#include <bits/stdc++.h>
int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	int h = ri();
	int w = ri();
	int x = ri() - 1;
	int y = ri() - 1;
	std::string s[h];
	for (auto &i : s) std::cin >> i;
	
	int cnt = -3;
	for (int i = x; i < h && s[i][y] != '#'; i++) cnt++;
	for (int i = x; i >= 0 && s[i][y] != '#'; i--) cnt++;
	for (int j = y; j < w && s[x][j] != '#'; j++) cnt++;
	for (int j = y; j >= 0 && s[x][j] != '#'; j--) cnt++;
	printf("%d\n", cnt);
	return 0;
}
#define ALL(x) (x).begin(), (x).end()
#include <bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 105;
ll n, x, ans;
ll a[N];

void solve(ll num) {
    ll r = x % num;
    ll cur = x / num;
    vector<vector<ll>> dp(num + 1, vector<ll>(num, -1));
    dp[0][0] = 0;
    for (int i = 0; i < n; ++i) {
        auto dp2 = dp;
        for (int j = 0; j < num; ++j) {
            for (int k = 0; k < num; ++k) {
                if (dp[j][k] != -1) {
                    ll nk = (k + a[i]) % num;
                    ll add = (k + a[i]) / num;
                    if (dp2[j + 1][nk] == -1) {
                        dp2[j + 1][nk] = dp[j][k] + add;
                    } else {
                        dp2[j + 1][nk] = max(dp2[j + 1][nk], dp[j][k] + add);
                    }
                }
            }
        }
        dp = move(dp2);
    }
    if (dp[num][r] != -1)
        ans = min(ans, cur - dp[num][r]);
}

int main() {
    ans = std::numeric_limits<ll>::max();
    cin >> n >> x;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 1; i <= n; ++i) {
        solve(i);
    }
    cout << ans << endl;
    return 0;
}
