Winning CB Scholarship

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner obj = new Scanner(System.in);
int n=obj.nextInt();
int m=obj.nextInt();
int x=obj.nextInt();
int y=obj.nextInt();

       int lo=0,ans=0;
       int hi=n;
       while(lo<=hi)
       {
           int mid = (lo+hi)/2;
           if((mid*x) <= (m +(n-mid)*y))
           {   ans=mid;
               lo=mid+1;
           }
           else
           {hi=mid-1;}
       }

System.out.print(ans);

}

}

3 out of 6 test cases are showing wrong answer.
please tell me the mistake in code above.