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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int lim = 31 - a + b;
    if (c <= lim) {
        cout << 1 << endl;
    } else if (d <= lim) {
        cout << 2 << endl; 
    } else {
        cout << 3 << endl;
    }
}