#include
using namespace std;
int main() {
int n,m,x,y;
cin >> n>> m>> x>> y;
int p = m / x;
if( p >= n){
cout << n;
}
else{
int l = n - p;
if( l > 1){
int z = m % x;
int k = (z + y) / x;
if( k < l){
cout << p + k;
}
else{
cout << p + k - 1;
}
}
else{
cout << n - 1;
}
}
return 0;
}