#include #include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 3000000000000000 int main(){ int X,Y,K,P; cin>>X>>Y>>K>>P; int turns = X+Y-K; int need = 0; if(Y%2==1)need = 1; if(P==-1)need ^= 1; int E; if(need==0){ E = min(turns-1,Y); } else{ E = min(turns,Y); } //cout<