import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

isInt :: Real a => a -> Bool
isInt x = x == fromInteger (round (realToFrac x))

times :: Integer -> Int
times x = (+1) . length $ takeWhile (not . isInt) $ map (\y -> 360*y `div` x) [1..]

solve :: Int -> Integer -> Int
solve n x = 360 * n `div` x

main = do
  x <- getInt
  print $ round $ solve (times x) x
