#include using namespace std; typedef long long ll; int main(){ ll a,b,c,d; cin>>a>>b>>c>>d; ll x=31-a+b; if(c<=x){ cout<<1; }else if(d<=x){ cout<<2; }else{ cout<<3; } }