#include #define rep(i,n) for(int i=0;i<(n);++i) using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int a,b,c,d; cin >> a >> b >> c >> d; int x = 31-a+b; if(x>=c) cout << 1 << endl; else if(x>=d) cout << 2 << endl; else cout << 3 << endl; }