#include #include #include #include #include using ll = long long; using namespace std; const int MOD = 1e9+7; int main() { int N, X, A, B, cnt1, cnt2; cnt1 = cnt2 = 0; cin >> N >> X >> A >> B; int x = X; while (!(x & (1<<(N-1)) || x == 0)) { x -= A; cnt1++; } x = X; while (!(x & (1<<(N-1)) || x == 0)) { x += B; cnt2++; } cout << min(cnt1, cnt2) << endl; return 0; }