let rec gcd m n =
  if m < n then gcd n m
  else if n = 0 then m
  else gcd n (m mod n)

let gcd_and_lcm a b =
  let g = gcd a b in
  let l = a * b / g in
  (g, l)

let main () =
  let n = Scanf.scanf "%d" (fun v -> v) in
  let g, l = gcd_and_lcm n 360 in
  Printf.printf "%d\n" (l / g)

let () = main ()
