X = int(eval(input()))



theta, k = 0, 0

while theta != 360:

    theta += X

    k += 1

    if theta > 360:

        theta -= 360

print(k)
X = int(eval(input()))

theta, k = 0, 0

while theta % 360 != 0 or theta == 0:

    theta += X

    k += 1

print(k)
X = int(eval(input()))
theta, k = 0, 0
while theta != 360:
    theta += X
    k += 1
    if theta > 360:
        theta -= 360
print(k)

X = int(eval(input()))
theta, k = 0, 0
while theta % 360 != 0 or theta == 0:
    theta += X
    k += 1
print(k)

-while theta != 360: +while theta % 360 != 0 or theta == 0: -    if theta > 360: -        theta -= 360