ONE morning a history teacher wakes up in Kiev to find himself elected president of Ukraine—thanks to a video secretly recorded by a pupil and uploaded to YouTube. It shows the teacher cursing Ukraine’s political class for their lies and its people for their indifference. “Our politicians don’t know history, but they are brilliant mathematicians: they all know how to add, divide and multiply their wealth,” he tells a colleague. The video goes viral, and a local oligarch-prime minister backs him in the hope of gaining a puppet. Instead, the new president imprisons the oligarch and goes after his cronies.

This is the plot of “Servant of the People”, a satirical television show that first aired in 2015. Since then 20m people—half of Ukraine’s population—have tuned in. Ironically, it plays on a channel owned by Igor Kolomoisky, an oligarch. Less amusing is that Vladimir Zelensky, the comedian who plays the teacher, is in some polls Ukraine’s second most popular presidential candidate, beaten only by Yulia Tymoshenko, a veteran populist. Petro Poroshenko, the incumbent, scores just 5%. The election may not be until next March, but the jostling for power is in full swing.

Ukrainian politics have long resembled an “operetta”, as Mikhail Bulgakov, a Kiev-born Russian novelist, scornfully described it in “The White Guard”, set in 1918 during a brief period of Ukrainian independence. A century later Ukraine is still struggling to assert its sovereignty in the face of Russian aggression and crippling corruption. “The state is not performing its basic functions of providing security and justice,” says Anatoly Grytsenko, a former defence minister and a presidential candidate running, unusually, without the support of oligarchs.

The job of regaining sovereignty is especially important for Ukraine, since Donald Trump feels no urge to defend it. If anything he appears to resent the country as a source of trouble for Paul Manafort, his former campaign manager, who went on trial this week in the United States for fraud charges stemming from his activities in Ukraine several years ago.

Yet, Mr Grytsenko points out, to be treated like a sovereign country Ukraine needs to behave like one. “We can’t blame Putin for internal corruption, deceit and lack of reforms,” he says. Over the past three years America and the European Union, along with Ukraine’s civil activists, have created the anti-corruption infrastructure needed to break up an entrenched system designed to siphon off public money into offshore accounts. This includes an investigative bureau (NABU), a special prosecution service and an anti-corruption court, finally set up in June under pressure from the IMF and activists.

Yet Ukraine’s rulers have done everything in their power to undermine these institutions from within. NABU has accused Nazar Kholodnitsky, the chief anti-corruption prosecutor, of subverting its investigations by leaning on his own prosecutors to drop cases, and tipping off suspects. (He denies these charges.) Last month prosecutors closed an embezzlement case against the son of Arsen Avakov, the powerful interior minister, which NABU had opened.

Vitaly Shabunin, head of the Anti-Corruption Action Centre, a civic organisation, says that the old system has been rocked but that it is now fighting back. He has been harassed by the authorities himself. On July 17th, as he campaigned for Mr Kholodnitsky to be fired, thugs attacked him with antiseptic dye in full view of the police.

“We are fighting for our life, and we have not got much time,” says Mr Grytsenko. His support has been rising despite his lack of money or access to the oligarch-controlled media. Some voters still crave honesty in their politicians. The risk is that the bloody operetta will prevail.