#include<bits/stdc++.h>
using namespace std;

int main(){
  int a, b, c, d;
  cin >>a>>b>>c>>d;
  cout << a*d-b*c <<endl;
}
  
#include <iostream>
using namespace std;
typedef long long ll;
ll x,y,a,b,cnt,A;
int main(void){
    cin>>x>>y>>a>>b;
    while(1){
        if(y/a<=x){
            cnt+=(y-x-1)/b;
            break;
        }
        if(x*a<x+b){
            x*=a;
            cnt++;
        }
        else{
            A=(x*a-x)/b;
            cnt+=A;
            x+=b*A;
        }
    }
    cout<<cnt<<endl;
}
