In 1800, Bavaria reluctantly fought on Austria's side against France, but in 1805 when Austria attacked Bavaria for the third time in 100 years, they found a powerful army. The Bavarians initially retreated, but only in order to link up with Napoleon's advancing army and to prepare the counter-attack, which took place quickly, methodically and thoroughly. 30,000 Bavarian troops took part in the successful Siege of Ulm and the consequent liberation of Bavaria. At the Battle of Austerlitz, the Bavarians secured the flanks and supply lines of Napoleon's army and in 1806-7 they forced several Prussian forts to surrender.