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