In Afghanistan, the Russians seem to be learning the hard way what other major powers painfully discovered long ago: latter-day imperialism is a mug's game -- nearly all loss, very little gain.

The Kremlin's inevitable post-mortem on the Afghan disaster could well begin with the Soviet leaders' asking themselves why France got out of Algeria and Indochina, why the Dutch let go of Indonesia, why Britain relinquished India and Rhodesia, and why the United States pulled out of Vietnam.

They all left because staying became too costly in men, money and bitter political division at home. The price included war and civil war, as well as violent and passive resistance, as in Afghanistan today.

When imperialism could be pursued on the cheap, as earlier in the century, it momentarily paid off. But that has not been possible since the end of World War II and the sweeping revolutionary rollback of colonialism. The irony is that the old colonial powers are enjoying a higher standard of living today than when they were uneasily presiding over burdensome empires.

It becomes clearer every day that the aggression against Afghanistan is the worst Soviet blunder since the 1962 Cuban missile crisis, a misadventure that culminated in a drastic shakeup of the Politburo and the purge of Nikita Khrushchev. With the prospect of things going from bad to worse in Afghanistan, it is a sound bet that, as in 1962, there will be an agonizing foreign-policy reappraisal in the Kremlin.

If so, there could be dividends for both Russia and the rest of the world, since it is hard to see how an objective review could fail to convince the Soviet leaders that the attempts to enlarge Russian hegemony beyond its accepted orbit have, on balance, been counterproductive.

Afghanistan is only the latest example of this. Moscow has been actively cultivating its poverty-stricken neighbor since the Afghan monarchy was overthrown in 1973 in favor of a republic. The republic, in turn, was over thrown in a 1978 Marxist coup. Since then, Moscow has lavished military and economic aid on the country in a futile effort to turn it into a supine satellite. Now, it has desperately resorted to outright armed occupation, but that has not succeeded either.

The U.S. government estimates it will take 400,000 or more Soviet troops to pacify Afghanistan. Would even that do the job? After all, America finally sent 500,000 troops to Vietnam, at a cost of $150 billion, yet the mission was a failure.

If the Russian leaders keep that grim example in mind, they will concentrate on finding a face-saving way of disengaging before getting in any deeper. As big and strong as the Soviet Union is, there is a limit even to its resources, which are already strained -- perhaps more than is generally realized.

Those who keep saying that "the Russians are coming" ought to take another look. In the last decade or two, their hegemonic setbacks have far exceeded their gains. The loss of China alone is greater than all the supposed gains elsewhere. Yet that is only the beginning.

Indonesia is the world's fifth most populous country. After Russia spent billions arming and training Indonesian army, the military used the weapons against the communists in a countercoup in which 500,000 suspected Marxists were slaughtered.

An even more critical setback was Russia's loss of its Middle East foothold when Egypt broke its friendship treaty with Moscow, repudiated loans exceeding $7 billion and expelled the Soviet military. Sudan followed suit. Russian influence has also dwindled or disapapeared in Somalia, Algeria, Ghana, Guinea, North Korea, Iraq, Bangladesh and India, among others.

Those who contend that Russian hegemony has made notable recent advances are reduced to citing five weak, insignificant countries: Afghanistan, South Yemen, Ethiopia, Angola and Mozambique. So far, they have been a continuous drain on Russia, with little or nothing to show on the plus side. Cuba, it might be added, is costing Moscow milions of dollars every day in subsidies.

According to a new study by the Center for Defense Information, 1958 was the high point of Soviet world influence. At that time, Soviet-influenced countries had 31 percent of the world's population and 9 percent of the world's GNP, not including the Soviet Union. Today, the Russians are "influencing only 6 percent of the world's population and 5 percent of the world's GNP, exclusive of the Soviet Union."

Russia has clearly been stung by the condemnation of both the Third World and the free world. Nevertheless, it is not going to be easy for it to admit failure in Afghanistan. The United States resisted pulling out of Vietnam for fear of looking like a "pitiful helpless giant," and now Moscow is faced with the same anxiety. But like the United States, Russia may soon find that hanging on can be more excruciating than getting out.