A, B, C, D = map(int, input().split(' ')) total = 0 for i in range(A): if 12 % ((i + 1) * (1 + C)) > 1 + C: break else: total += 1 if total * C != B: print('0') else: print(total)