policies before Japan did, starting with the Ming implementing Haijin from 1371. Unlike sakoku, foreign influences outside East Asia were banned by the Chinese and Koreans as well, while Rangaku allowed Western ideas other than Christianity to be studied in Japan. China was forced to open up in the Treaty of Nanking and in subsequent treaties, following its defeat in the First Opium War. Joseon, which had developed a reputation as a hermit kingdom, was forced out of isolationism by Japan in the Japan–Korea Treaty of 1876, making use of gunboat diplomacy which had been used by the United States to force Japan to open up. Trade under During the period, Japan traded with five entities, through four "gateways". The largest was the private Chinese trade at Nagasaki (who also traded with the Ryūkyū Kingdom), where the Dutch East India Company was also permitted to operate. The Matsumae clan domain in Hokkaidō (then called Ezo) traded with the Ainu people. Through the Sō clan of Tsushima, there were relations with Joseon-dynasty Korea. Ryūkyū, a semi-independent kingdom for nearly all of the Edo period, was controlled by the Shimazu clan of Satsuma Domain. Tashiro Kazui has shown that trade between Japan and these entities was divided into two kinds: Group A in which he places China and the Dutch, "whose relations fell under the direct jurisdiction of the at Nagasaki" and Group B, represented by the Korean Kingdom and the Ryūkyū Kingdom, "who dealt with Tsushima (the Sō clan) and Satsuma (the Shimazu clan) domains respectively". Many items traded from Japan to Korea and the Ryūkyū Kingdom were eventually shipped to China. In the Ryūkyū Islands and Korea, the clans in charge of trade built trading towns outside Japanese territory where commerce actually took place. Due to the necessity for Japanese subjects to travel to and from these trading posts, this resembled something of an outgoing trade, with Japanese subjects making regular contact with foreign traders in essentially extraterritorial land. Commerce with Chinese and Dutch traders in Nagasaki took place on an island called Dejima, separated from the city by a narrow strait; foreigners could not enter Nagasaki from Dejima, nor could Japanese civilians enter Dejima without special permission or authorization. For the island's inhabitants, conditions on Dejima were humiliating; the police of Nagasaki could harass them at will, and at all times a strong Japanese guard was stationed on the