program takahashikun_the_strider
  implicit none
  integer :: x, s = 360, i
  read(*,*) x
  do i = 2, 360
    do while (mod(x, i) == 0 .and. mod(s, i) == 0)
      x = x / i
      s = s / i
    end do
  end do
  write(*,'(i0)') s
end program takahashikun_the_strider