never been restored. Mongols turned to the south and devastated regions along rivers Váh and Nitra. Only the strong castles, e.g., Trenčín, Nitra, Fiľakovo () and fortified towns could resist attack. A part of the unprotected population escaped to the mountains and rough terrain where they built hill forts and camps. Most affected areas were the southwest Slovakia, Lower Pohronie to Zvolen and Zemplín. It is estimated that at least a third of population died from famine and epidemics. Following the withdrawal of the Mongol army, Frederick II, Duke of Austria invaded the country. In July 1242 his army reached Hlohovec but the Hungarian army, mainly thank to troops from Trenčín and Nitra counties repelled the attack. Bohumír (Bogomer), the župan of Trenčín who played an important role in the suppression of Austrian units, later led the army send to help Bolesław V the Chaste (son-in-law of the Hungarian king) attacked by Konrad I of Masovia. The army consisted mainly of soldiers from the ethnic Slovak counties. Development of counties and towns The royal administration of the territory was developing gradually during the 11-13th centuries: new counties were established with the partition of existing ones or central counties of the kingdom expanded their territory northward today's Bratislava (, ), Trenčín, Gemer-Malohont () and Novohrad (), while the kings' private forests were organised into "forest counties" around Zvolen and Šariš Castle (). Following the occupation of his brother's duchy, King Coloman set up (or re-established) the third bishopric in present-day Slovakia. Some of the towns in present-day Slovakia were granted special privileges already prior to the Mongol invasion: Trnava (1238), Starý Tekov (1240), Zvolen and Krupina (before 1241). Following the withdrawal of the Mongol troops (1242), several castles were built or strengthened (e.g., Komárno, Beckov () and Zvolen) on the order of King Béla IV. In addition to a relatively developed network of castles, agglomerations of an urban character became more important. Medieval towns should serve both to economic and defensive purposes. The territory of present-day Slovakia was rich in raw materials like gold, silver, copper, iron and salt and therefore the mining industry developed gradually in the region. The development of the mining industry and commerce strengthened the position of some settlements and they received privileges from the kings. The list of towns with the earliest charters contains Spišské Vlachy (1243), Košice (before 1248), Nitra (1248), Banská Štiavnica (1255), Nemecká