TALLINN, ESTONIA -- This medieval city of castles and cobbled streets rang with optimism last summer when Estonia finally broke free after five decades of domination by the Soviet Union. Now people are starting to feel that achieving independence was the easy part.

Today, this fledgling country of 1.6 million people just south of Finland is on bread rations. Only children under 4 years of age can receive milk. Many homes are chilly and without hot water, and the government soon may have to evacuate about 200,000 residents -- nearly half the capital's population -- to wood-heated homes outside the city because it is running out of heating oil.

The smallest in population of the Soviet Union's 15 former republics and its most prosperous, Estonia is a bellwether of the difficulties other republics may face as they begin to disentangle from the collapsed Soviet empire.

Without the central command system that bound them all to each other and to Moscow, economic relations have become chaotic and unpredictable, and republics are scrambling to feed their people and resuscitate their economies. Many expected trouble, but few expected it to hit this hard, this soon.

Last week, the Estonian prime minister, Edgar Savisaar, was forced to resign over the economic situation. {On Monday, the legislature named Transport Minister Tiit Vahi as the new prime minister, the Estonian news agency reported.}

"I don't think we fully realized how difficult it was going to be, or at least I didn't," said Kristel Murel, 35, an Estonian housewife with a 4-year-old daughter. "Everything is going downhill very fast."

Like the rest of the world, Estonia was not prepared for how quickly the Soviet empire would unravel, forcing the republic to make its way in the real world. Estonia, which declared its independence in the midst of the coup attempt against Soviet president Mikhail Gorbachev last August, was recognized by most of the world within days and was officially set free by Gorbachev shortly afterward.

For more than 50 years, since Estonia was forcibly incorporated into the Soviet Union by agreement between Adolf Hitler and Joseph Stalin, its economy was governed not by laws of supply and demand but by decisions of Moscow bureaucrats. Moscow determined what Estonia would produce and in what quantities, to whom it would sell and where it would buy supplies. Most raw materials came from Russia, including crude oil, animal fodder and wheat, and 95 percent of its exports, including electricity and dairy products, "went east," as they say here.

The system was designed to block self-sufficiency and keep the republics dependent on Soviet central authorities and on one another. Estonia could not process its own oil but had to get it from Lithuania. And Moscow determined that Estonia needed oil-storage facilities only large enough to stockpile fuel for a month. Meanwhile, Estonia supplied electricity for the St. Petersburg region in Russia.

"In a way, we lived in a very closed world," said Estonian Economics Minister Jaak Leimann. "We had access to resources from the Soviet empire, getting them for rubles at very cheap prices. We also sold almost all our products to the rest of the Soviet empire, also for very cheap prices."

In all the planning for Estonian independence, it was assumed and even hoped that this system, and the Soviet Union, would continue, giving Estonia time to ease slowly into the Western economic sphere. "We wouldn't have minded if the Soviet Union had gone on for a little longer. A very messy neighbor is worse than a predictable one," said Leimann, whose office is decorated with a replica of the Statue of Liberty.

Estonia no longer has access to cheap, subsidized raw materials from Russia, and it simply cannot afford the new, much higher prices Russia now is demanding.

At the same time, this tiny country has not yet developed its industry to start selling products abroad for much-needed hard currency. And Russia, its main customer in the past, has little interest in buying what Estonia has to sell.

"Unfortunately, Russia, being on the verge of hunger right now, is not interested in buying our clothes. It only wants food," said Leimann. "When you're hungry, you don't buy furniture. You want meat or dairy products or fish," products that Estonia now must conserve for its own people or, in small amounts, sell to the West for desperately needed income. The result is a dramatic fall in both industrial and agricultural production and a full-fledged energy and food crisis that is unlikely to abate soon.

The lack of promised crude oil supplies from Russia has meant a sharp cutback in public services. Most snowplows and garbage trucks are idle; public transport is difficult to find. Gas for cars is either not available or exorbitantly priced.

Homes in Tallinn, meanwhile, are chilly, often at 57 degrees or lower. Even the fancy new Palace Hotel, where several foreign embassies set up shop after establishing diplomatic relations with Estonia, is having to provide patrons with extra blankets. Elsewhere in Tallinn, hot water has been cut off, leaving residents to fend for themselves as winter temperatures plummet.

"We heat water on the stove," shrugged Alexander Ilyin, a theater director and Tallinn resident who has been without hot water in his apartment for more than a week. Ilyin's office, on the other hand, has hot water but no heat.

The Estonian government has dispatched delegations to Moscow, neighboring Scandinavian countries and the two other Baltic states to beg for help, warning that its fuel supplies could run out any day. Some help has come from Lithuania, which has large stores because Soviet authorities put an oil processing plant there, and from Sweden, which, like the other Scandinavian countries, has been investing in the Baltic states as part of a future Nordic sphere.

But officials here say the promises of aid are not enough. Already, individuals in the capital can get only three loaves of bread a month, or about two slices a day, a hardship in a country where bread customarily has been consumed at every meal.

The problem again is mostly one of historical dependence on Russia. This year, with Russia facing its own food shortages, Estonia has received hardly any wheat for bread. At Estonia's largest bread factory, Leibur, which produces more than 40 percent of the country's bread, officials said they have received only 622 tons of the 14,400 tons they requested from Russia for 1992. Normally an entire year's supply would have arrived by now.

Meanwhile, demand for bread has shot up, partly because other goods have vanished from stores and partly because prices on most other foods have been freed of government controls and are climbing by the day, while bread prices remain fixed and low. In some cases, farmers have resorted to feeding their animals bread because a bad harvest in Russia has meant a reduction in the supply of animal fodder. The fodder shortage, in turn, has led to a reduction in livestock and a severe crisis in milk production.

At Leibur's main bread factory in Tallinn, commercial manager Ants Promann said it has been almost impossible to get not only the wheat flour Russia contracted to send but also sugar syrup promised by Ukraine, malt promised by Belarus and the nuts and cocoa that in the past the Soviet government imported and then doled out to the republics.

"It all happened very suddenly. The old system has broken down, but the new system doesn't function yet," said Promann.

Promann and many other Estonians said they are confident that somehow Estonia will muddle through the current crisis, in part because for several years now it has been orienting itself toward the West. In many ways, this city feels more like a piece of Europe than of the Soviet Union, with its clean, glass-fronted stores and coffee shops that actually serve coffee.

Tallinn's old town is filled with shops that are part-owned by foreign companies, selling clothes, toys and food from Germany, the United States and, especially, Finland, which is just a four- or five-hour boat ride away. The goods, however, are sold only for foreign currency. Many Estonian doctors, academics and other professionals work in the fields of Finland during the summer, earning more in foreign currency in a couple of weeks than they earn in rubles in a year.

Still, there is no escaping the widespread problems. At Tallinn's central market, pensioners complain about constantly rising prices, which make it impossible to know from day to day what they will be able to afford.

"What can we eat anymore?" said Asya Baranova, 66, as she waited in a frigid hour-long line to buy some frozen smelts that a saleswoman was hacking with an ax on the snowy ground. "Every day, the price goes up and up."

Baranova is one of the ethnic Russians who make up about 30 percent of Estonia's population and who have been unsettled by the splitting up of the Soviet Union and the transformation of this republic into an independent country.

Gesturing to the empty market stalls, she said: "It's bad to be a separate country; now they don't give us anything, and we don't give them anything." How, she asked, can anyone survive like that?