Bavaria as the third-largest state in Germany after 1815 enjoyed much warmer relations with France than the larger Prussia or Austria. From 1670 onwards the two countries were allies for almost a century, primarily to counter Habsburg ambitions to incorporate Bavaria into Austria. This alliance was renewed after the rise of Napoleon to power with a friendship treaty in 1801 and a formal alliance in August 1805, pushed for by the Bavarian Minister Maximilian von Montgelas. With French support Bavaria was elevated to the status of a Kingdom in 1806. Bavaria supplied 30,000 troops for the invasion of Russia in 1812, of which very few returned. With the decline of the First French Empire Bavaria opted to switch sides on 8 October 1813 and left the French alliance in favour of an Austrian one through the Treaty of Ried.