#include
#include
using namespace std;
int main() {
int n, x, y, v;
cin >> n >> x >> y >> v;
int tvrdina[n][n];
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
if(i % 2 == 0) {
if(j % 2 == 0) {
tvrdina[i][j] = 0;
}
else {
tvrdina[i][j] = 1;
}
}
else {
if(j % 2 == 0) {
tvrdina[i][j] = 1;
}
else {
tvrdina[i][j] = 0;
}
}
}
}
int titanik[n][n];
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
if(j < n - i) {
titanik[i][j] = 1;
}
else {
titanik[i][j] = 0;
}
}
}
if(v == titanik[y][x] and v == tvrdina[y][x]) {
cout << 3 << endl;
}
else if(v == tvrdina[y][x]) {
cout << 1 << endl;
}
else if(v == titanik[y][x]) {
cout << 2 << endl;
}
else {
cout << 4 << endl;
}
return 0;
}