a,b,c,d=map(int,input().split())

if c<=31-a+b:
  print(1)
elif d<=31-a+b<c:
  print(2)
else:
  print(3)