The United States acquired almost all of the area of South Dakota from France in 1803 as part of the Louisiana Purchase. A small portion in the northeast part of the present-day state was added by a convention signed with Great Britain in 1818. Dakota Territory was organized on March 2, 1861, from unorganized area formerly within Minnesota Territory and part of Nebraska Territory. Dakota Territory included all of the present-day states of North Dakota and South Dakota, most of Montana, the northern half of Wyoming, and a small part of Nebraska. The territory was reduced in 1863 with the organization of Idaho Territory, enlarged in 1864 with the addition of most of the remainder of present-day Wyoming, and again reduced with the organization of Wyoming Territory in 1868. In 1882, the state of Nebraska acquired an area north of the Keya Paha River and Niobrara River. South Dakota was admitted to the Union simultaneously with North Dakota on November 2, 1889, as the 39th and 40th states, with generally the same boundary as the present state.