#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int a, b, c, d; cin >> a >> b >> c >> d; if (a + c <= 31 + b) { cout << "1" << endl; } else if (a + d <= 31 + b) { cout << "2" << endl; } else { cout << "3" << endl; } }