n,m,p,q = map(int,input().split()) leaf = n ans = 0 p -= 1 while leaf > 0: if p<=ans%12