 The sperm whale has the longest intestinal system in the world , exceeding 300 m in larger specimens . Similar to ruminants the sperm whale has four stomachs . The first secretes no gastric juices and has very thick muscular walls to crush the food ( since whales cannot chew ) and resist the claw and sucker attacks of swallowed squid . The second stomach is larger and is where digestion takes place . Undigested squid beaks accumulate in the second stomach – as many as 18 @,@ 000 have been found in some dissected specimens . Most squid beaks are vomited by the whale , but some occasionally make it to the hindgut . Such beaks precipitate the formation of ambergris . 
