In July and August 1433, Švitrigaila and his Livonian allies raided Lida, Kreva and Eišiškės and devastated the suburbs of Vilnius, Trakai and Kaunas. The hostilities were briefly stopped by horse plague. When Jogaila died in May 1434, the Order resumed its backing for Švitrigaila, who rallied his supporters, including knights from the Livonian Order, the Orthodox dukes, and his nephew Sigismund Korybut, a distinguished military commander of the Hussites. In July 1435, Švitrigaila foiled a coup against him in Smolensk. Coup leader Orthodox bishop Gerasim, consecrated as Metropolitan of Moscow in 1432, was burned at the stake. The final battle, at Pabaiskas, was fought in September 1435 near Ukmergė , northwest of Vilnius. It is estimated to have involved 30,000 men on both sides. Švitrigaila's army, led by Sigismund Korybut, was split by the attacking Lithuanian-Polish army, led by Michael Žygimantaitis, and soundly defeated. Švitrigaila, with a small group of followers, managed to escape to Polotsk. The Livonian Order had suffered a great defeat, sometimes compared to that which had been inflicted on the Teutonic Knights at Grunwald in 1410. On 31 December 1435 the Teutonic Knights signed a peace treaty at Brześć Kujawski. They agreed to cease their support for Švitrigaila, and in the future to support only Grand Dukes who had been properly elected jointly by Poland and Lithuania. The treaty did not change the borders that had been set by the Treaty of Melno in 1422. The Peace of Brześć Kujawski showed that the Teutonic Knights had lost their universal missionary status. The Teutonic and Livonian Orders no longer interfered in Polish-Lithuanian affairs; instead, Poland and Lithuania would involve themselves in the Thirteen Years' War , the civil war that would tear Prussia in half.
Question: What happened first: the coup or the Treaty of Melno?
Answer: a coup