#include<iostream> using namespace std; int main(){ int x,y,p,q; cin>>x>>y>>p>>q; cout<<min(x,min(x-p,min(q,y-q))); return 0; }
#8有奇错