a,b,c,d=map(int,input().split()) if c<=31-a+b: print(1) elif d<=31-a+b