program AGC046A
    implicit none
    integer(8)::X,i,y
    read*,X
    do i=1,360
        y=X*i
        if(mod(y,360)==0)then
            print'(i0)',i
            exit
        end if
    end do
end program AGC046A