Canada gradually gained independence from Britain in the late 19th century through agreements that gave Canadians more autonomy. The War of 1812 helped foster a sense of Canadian national identity by uniting French and British Canadians against a common American enemy. Despite their small population and greater American resources, Canadian forces were able to repel multiple US invasions. The Louisiana Purchase in 1803 doubled the size of the US, acquiring territory containing 15 current states from France for $15 million. This expanded US control of the key Mississippi River trade route and prevented European powers from blocking access.