#include<bits/stdc++.h>
using namespace std;
int main() {
long long n,m,x,y;
cin>>n>>m>>x>>y;
long long res=m/x;
m=m%x;
if(res>=n)
cout<<n<<endl;
else
{
n=n-res;
long long i=0;
while(i+1<n)
{
m+=y;
n–;
if(m>=x)
{
long long j=m/x;
if(i+j!=n+1)
{
res=res+(m/x);
i=i+(m/x);
}
else
{
res=res+(m/x)-1;
i=i+(m/x);
break;
}
m=m%x;
}
}
cout<<res<<endl;
}
return 0;
}