Jose de San Martin, born in eastern Argentina in 1778, liberated much of South America from the Spanish between 1812 and 1821. His father was a Castilian army officer assigned there. As a child, San Martin moved with his family to Buenos Aires, and then to Spain. He became a military cadet at age 12, entering the Seminario de los Nobles, an aristocratic training ground for service to the Crown. By age 16 he had been captured in battle twice: once after surrendering the fort at Oran in North Africa, and once among captured and fleeing Spanish forces. San Martin was promoted to the rank of second lieutenant in 1795, and later fought in the Spanish invasion of Portugal. While the Spanish attempted to resist the French in 1810 and fought for their own country, San Martin began to be influenced by such philosophers as Montesquieu and Locke, and befriended idealistic men like Bernardo O'Higgins. At this point, San Martin's focus switched to idealism, and he became committed to the political ideals of democracy. It was this commitment that would later serve South America. San Martin decided to immediately put these ideals to good use, and set sail for Buenos Aires at the age of 33 with the intention of helping the independence movement. He married a 15 year old at the age of 35, and began training troops. His first battle with the Spanish came one year after arriving in the New World; his 120 grenadiers held against a Spanish force of 250 men. Although San Martin was crushed under his horse, but saved by another man, the battle was considered a success and brought hope and good morale to the desparate independence movement in South America. He later was appointed the governor of the province of Cuyo, and used his position to plan and finance an over-the-mountains invasion of Lima (the eventual goal of the independence movement). San Martin drafted as many troops as he could obtain, and by late 1816 the Army of the Andes was ready. Upon crossing the Andes, the majority of the horses and mules were lost, and no man was spared from attacks of Vertigo... the dangerous feat could be compared to the likes of Hannibal or Napoleon. However, both San Martin's first and second attacks failed. In 1818, the Chileans formally declared their independence. San Martin built up a naval force, and was able to overpower and defeat anything the Spanish could throw at them. Using his naval power, San Martin was able to liberate Peru.