#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
 
using VI = vector<int>;
 
int g(VI a, int i, int d);
 
int f(VI const& v) {
    int i = find(cbegin(v), cend(v), 0) - cbegin(v);
    return i < v.size() ? g(v, i, 0) + g(v, i, 1) : 1;
}
 
int w;
 
int g(VI v, int i, int d) {
    int j = i + (d ? w : 1);
    if (j >= v.size() || !(d || j % w) || v[j]) {
        return 0;
    }
    v[i] = v[j] = 1;
    return f(v);
}
 
int main() {
    int h, a, b;
    scanf("%d%d%d%d", &h, &w, &a, &b);
    VI v(2 * a);
    v.insert(end(v), b, 1);
    int r = 0;
 
    do r += f(v);
    while (next_permutation(begin(v), end(v)));
 
    printf("%d\n", r);
    return 0;
}

#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define reps(i,s,n) for(int i=s;i<n;++i)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int ans0[4] = { 0,0,0,0 };
int ans1[4] = { 1,1,1,1 };
int ans2[4] = { 6,2,4,8 };
int ans3[4] = { 1,3,1,3 };
int ans4[4] = { 6,4,6,4 };
int ans5[4] = { 5,5,5,5 };
int ans6[4] = { 6,6,6,6 };
int ans7[4] = { 1,7,9,3 };
int ans8[4] = { 6,8,4,2 };
int ans9[4] = { 1,9,1,9 };

int main()
{
	ll a, b, c;
	cin >> a >> b >> c;
	int mod = 4;
	//コーナーケース
	if (b % mod == 2)
	{
		if (c == 1) b = 2;
		else b = 0;
	}
	else
	{
		//cが偶数なら2乗、奇数なら1乗（なにもしない）
		if (c % 2 == 0) b *= b;

		b %= mod;
	}
	a %= 10;
	int ans = 0;
	if (a == 0) ans = ans0[b];
	if (a == 1) ans = ans1[b];
	if (a == 2) ans = ans2[b];
	if (a == 3) ans = ans3[b];
	if (a == 4) ans = ans4[b];
	if (a == 5) ans = ans5[b];
	if (a == 6) ans = ans6[b];
	if (a == 7) ans = ans7[b];
	if (a == 8) ans = ans8[b];
	if (a == 9) ans = ans9[b];

	cout << ans << endl;
}