In August, the vessels in Bermuda sailed from the Royal Naval Dockyard and St. George's to join those already operating along the American Atlantic coast. After defeating a US Navy gunboat flotilla, a military force totaling 4,370 (composed of British Army, Royal Marines, and Royal Navy detachments for shore service) under Ross was landed in Virginia. After beating off an American force of 1,200 on the 23rd, on the 24th they attacked the prepared defenses of the main American force of roughly 6,400 (US Army soldiers, militiamen, US Marines, and US Navy sailors) in the Battle of Bladensburg. Despite the considerable disadvantage in numbers (standard military logic dictates that a three-to-one advantage is needed in carrying out an attack on prepared defences) and sustaining heavy casualties, the British force routed the American defenders and cleared the path into the capital (President James Madison and the entire government fled the city, and went North, to the town of Brookeville, Maryland).