a, b, c, d = map(int, input().split()) x = b + 31 - a print(1 if c <= x else 2 if d <= x else 3)