Face it: Both the Republican and Democratic parties are in trouble. Neither can be sure which is in worse shape. So it behooves them both to do something right for a change.

What? Reach a budget deal that ends threats of government shutdowns and debt defaults, restores confidence among both foreign and domestic investors, and convinces the public that federal politicians can govern.

Will it be hard to get a deal — especially by the mandated deadline of Dec. 15? Of course. But both sides know what needs to be done — reform entitlements to get the country’s long-term debt under control, reform taxes to make the economy more productive, and lift the budget sequester’s stranglehold on domestic spending and defense.

The two people in charge of the House-Senate budget conference, Sen. Patty Murray, D-Wash., and Rep. Paul D. Ryan, R-Wis., are among the smartest, most flexible and well-meaning people in Congress.

The problem, of course, lies in political rigidity among Senate Democrats and House Republicans. If there’s any hope at all of a deal, there’s got to be leadership from those designated to lead: President Barack Obama and Republican leaders Mitch McConnell of Kentucky and John A. Boehner of Ohio.

The impetus for all concerned — besides the obvious one of getting the country out of deep trouble — is that neither party can be sure whom the public is madder at, short and long term.

After the government shutdown fiasco, it seemed clear that the GOP was in the hole and Democrats were riding high, thinking they could hold the Senate this year, maybe win back the House and — given the civil war raging within the GOP — elect Hillary Rodham Clinton in 2016.

That’s all in doubt now, thanks to the utter incompetence and duplicity the Obama administration has shown around the launch of Obamacare — but also because of the fundamental doubts it raises about government (Democrats being the “government party”).

Democrats claim that HealthCare.gov will get fixed shortly and there will be many more “winners” than “losers” under Obamacare. Don’t bet on it. Government IT is a regulation-locked mess (except at the National Security Agency) and cost explosion is baked into the ingredients of Obamacare.

Moreover, Democrats can’t be entirely sure that the sluggish pace of economic growth and the Obama administration’s multiple failures in foreign policy (recently presided over by Clinton) won’t make voters decide it’s time for a change.

Yes, if the GOP nominates a “whack job” presidential nominee — Sens. Ted Cruz of Texas and Rand Paul of Kentucky immediately come to mind, along with ex-Sen. Rick Santorum of Pennsylvania — 2016 could be a wipeout as total as 1964, when the GOP picked Sen. Barry Goldwater.

But for all its wandering in the extremist wilderness, the GOP presidential primary process often (in fact, usually) ends up picking its most electable candidate. New Jersey Gov. Chris Christie would be formidable — and would ride hard on every failure of Democratic policy.

Republicans have terrible demographic problems, as everyone knows. But Christie just might break through among Latinos and younger voters unable to get good jobs in the Obama economy — especially if he can devise a positive GOP agenda that will convince middle-class voters he’s on their side.

Obama’s latest Gallup approval rating is down to 40 percent, close to his lowest ever. And the George Washington University Battleground survey shows that 73 percent of voters think the country is on the “wrong track.”

Those numbers should not inspire euphoria in the party in control of the White House. It’s true, that same poll shows congressional Republicans with just a 27 percent favorable rating to 41 percent for congressional Democrats (and a surprising 32 percent for the tea party).

But the poll’s generic 2014 congressional ballot shows nearly a tie, Ds 44 to Rs 41, and the Ds barely win, 39 percent to 33 percent, as the party most capable of getting things right in Washington. This doesn't look like the makings of a “wave” election.

The fact is, the public is justifiably fed up with both parties. Congress’ approval is in single digits and 58 percent of voters say they’d vote against their own member and “give someone else a chance.”

Just imagine what a reversal a budget deal would engender! It may be unrealistic to expect a “grand bargain” — “leaders” in both parties say so — but Ryan and Murray ought to give it a try.

If they can’t pull it off, they could begin making down payments — some entitlement reform, some closing of tax loopholes and lowering of rates, and at least a modification of the across-the-board slashing required by the budget sequester.

To get any kind of deal, Democrats are going to have to give up on raising more taxes and rely on the supply-side growth effects of tax reform to produce more revenue.

Republicans would have to “give” on their love affair with the sequester.

That’s where leadership is required. Without it, the government could shut down again on Jan. 15 and a debt default could occur in February or March. That prospect — or even another last-second can-kicking exercise — ought to scare both parties.