FIRST OF TWO PARTS.

It was the early 1980s, and San Francisco Mayor Dianne Feinstein was driving around the city when she happened upon something she had never seen before: Someone was eating out of a garbage can.

Around that time, Jesse Smith Jr. stood dazed on the corner of Market and Seventh streets. He was flying on cocaine and speed, disheveled, filthy and worn out from living in the back of a truck.

For San Francisco, it was the start of a painful civic journey that continues today for a city that many say has the nation's worst homeless crisis. For Smith, it was the beginning of a long and often humiliating voyage from the streets to emergency rooms to detox and back again.

Two decades have passed. Four mayors have reigned and whiplashed the city with four different homeless policies. Hundreds of millions of city dollars have been spent. Yet there are more people than ever sleeping in San Francisco's shelters, hospitals, parks, downtown sidewalks and the once-immune outer neighborhoods.

This fall, a victorious mayoral candidate will inherit this disturbing legacy. Frustrated residents believe that homelessness is the city's No. 1 problem. Tourism industry leaders are concerned that the homeless are scaring away visitors.

The homeless say they are struggling through a maze of city services with long waiting lists. And it's all made worse by a ceaseless political stalemate -- between public officials and homeless advocates -- over everything from police enforcement to shelter redesigns.

The city is still overwhelmed by the homeless population -- the addicts, the mentally ill, the poor -- each of whom, like Smith, could take a decade and more to get off the streets.

But the crisis did not just start one foggy San Francisco day in the 1980s. The problems were building for at least a decade before City Hall or Jesse Smith sought help.

Smith, now 53, grew up in the Pink Palace in the Western Addition neighborhood, once the most notorious public-housing project in San Francisco. He remembers most of his neighbors were like his own family: Single moms struggling to raise kids drawn to the streets.

His father left when Smith was 2. Run-ins with truant officers started when he was 5, and he ended up in juvenile hall for the first time for fighting and truancy when he was 13.

"I started drinking to get drunk at 12 years old," Smith said, remembering how he and friends stole wine from the neighborhood grocery.

"This is where my illusions started." He felt like a big man around the old Pink Palace and in the government-subsidized housing in Hunters Point, where he later lived. He spent his teenage years and his 20s doing coke and selling dope. He was proud of his street names. Sweet Jay. Cool Breeze. The Man.

When he grew older, when he started using crack and running out of money, he slept on friends' couches.

"You could always find someone who hadn't bottomed out yet and bunk with them," he said.

"But I knew I was at my own bottom when I ended up downtown and I didn't recognize anything." That's when Smith noticed all the other people sleeping on the streets.

Around the same time, Mayor Dianne Feinstein gathered religious leaders together in 1982 to discuss a shocking wave of homeless people on city streets.

The solution, they thought, was to temporarily set up cots and soup kitchens in a few church basements.

What they didn't realize then was they faced the genesis of a generational crisis brought on by complicated social factors out of their control.

More than a decade earlier, then-Gov. Ronald Reagan had signed legislation to severely limit involuntary commitment of mental health patients. State mental hospitals emptied, but the expected funding and support for community psychiatric services and board-and-care homes shriveled, leaving many mentally ill people with fewer places to go.

Meanwhile, Vietnam vets were returning home with post traumatic stress disorder. Real estate prices were climbing. The economy was tanking. Federal spending on housing for the poor was being cut severely. And cheap drugs and alcohol were fueling addiction throughout urban America.

"I lived in the city all my life, and I'd never seen anyone eating out of a garbage can before," said Feinstein, today a U.S. senator.

The Rev. Cecil Williams of Glide Memorial Methodist Church, which now feeds, employs and houses thousands of homeless, said he was first alerted to the problem by a few church ladies who had been feeding needy people in their Tenderloin neighborhood. Since 1969, they had been holding a weekly potluck of home-cooked meals, but by 1980, they had to kick their cooking into overdrive to meet demand.

During the long, wet winter of 1982, Mayor Feinstein set up a system of emergency winter shelters with churches, including Glide, and she later added cheap hotels. Williams said he brought in 200 cots, but there were always people left without a bed.

At the time, Feinstein said, she thought homelessness was only a temporary problem, and the solution was to provide short-term housing. Her attention was also split with the emerging AIDS epidemic.

Her system of church-based winter shelters and homeless health care programs became the basis of today's system.

Feinstein's critics, who have the benefit of hindsight, say her homeless policy launched San Francisco on the wrong course. Instead of creating affordable housing, her programs created a permanent transient population, said Randy Shaw, director of the Tenderloin Housing Clinic, which started in 1980 to help poor people find permanent low-income housing.

Jesse Smith was oblivious to the politics swirling around him, but he saw his first flicker of hope.

The day that Smith stood dazed on Market Street in the early 1980s, a woman from the Salvation Army walked by, looked him over and bluntly said, "You look pretty bad."

She convinced him to check into a three-day detox program.

It was just the start. The seduction of the alcohol and the crack pipe proved too strong, and Smith would stay addicted and homeless for the next decade, bouncing in and out of the city's emerging homeless programs.

When he had money from drug sales, sidewalk junk sales or singing to tourists for spare change, he'd spend a night in a cheap motel. He sought detox programs only when he felt too broke or too tired. He avoided the shelters.

"One night at a shelter I got up in the middle of the night to use the bathroom," Smith said. "I was coming off alcohol and in a stupor. I couldn't find my bed when I came back, so I left. I figured if I'm going to be lost in here, I might as well be lost on the streets."

Former social worker and Assemblyman Art Agnos took over the mayor's office in 1988, and he began regarding the homeless situation as a permanent crisis.

Agnos instructed his staff to look beyond Feinstein's shelters and address why people were homeless.

A year later, Agnos unveiled "Beyond Shelter," an ambitious plan written by Bob Prentice, the city's homeless coordinator, to move the down-and-out into affordable housing. The city would start by building two large "multi- service centers" -- the first city-owned shelters -- that would assess clients, determine their problems and get them to counseling, detox or health services. And there would be support staff to help them transition back to independent living.

The plan is still seen by many social workers and advocates as the model homeless policy -- one never fully implemented.

But residents grew impatient with Agnos as more homeless people appeared on the streets during his term. Looking back, Prentice said the mayor's grand promises created high expectations that ultimately sank him.

In a 1990 speech to the Union Square Association, Agnos vowed to end homelessness: "We can end sleeping on the streets as a commonplace occurrence as we see it today, and we can do that this year."

Less than a year after Agnos took office, however, hundreds of homeless people settled in at Civic Center Plaza, right outside the mayor's City Hall balcony. They had tents and even put up a Christmas tree.

Agnos refused to evict them until his two shelters were built, ignoring staff warnings about political suicide.

"What better place to keep them than in front of me?" Agnos said, unapologetic. "It kept me on my toes."

The local press dubbed it "Camp Agnos" -- a lasting symbol of his four- year term that contributed to his loss to Police Chief Frank Jordan in 1991.

The city's homeless problem was exacerbated by the 1989 Loma Prieta earthquake. About 10 residential hotels were damaged, leaving hundreds of poor tenants on the streets.

Agnos' two shelters opened in 1990, largely in response to the quake, and remain the city's largest.

Yet critics like Paul Boden, head of the Coalition on Homelessness, said public pressure from fed-up residents forced Agnos to open the shelters before they were ready. The shelters ended up with case managers who were equipped only to make aid referrals. Boden said it was up to the homeless to follow up and get themselves enrolled, and then they'd likely find themselves on a waiting list.

The shelters became overcrowded, he said, so many of the street people just stayed outdoors.

Smith was still out there among them.

In 1990, after his mother succumbed to a long fight with cancer, Smith fell into an emotional tailspin. He imagined -- hoped -- he would die before her.

Smith had begun seeing a therapist at the free Tom Waddell clinic. But alcohol was still his daily drug and crack his luxury. He sold drugs to buy drugs and used money from his federal disability checks, and when that ran out, he received city General Assistance grants.

In 1991, Smith was encouraged by his therapist -- the first steady influence in his life -- to attend 12-step meetings and enter a work therapy program through St. Anthony's, where he served meals to the homeless. He felt better, skipped out on the program and rented an apartment in the Tenderloin.

It was a false sense of recovery. Smith fell, reeling backward toward drugs:

"I was doing in there (the apartment) what I was doing on the streets."

He lost his apartment and was homeless again.

When Frank Jordan campaigned for mayor in 1991, the career cop played on residents' frustration with the increasingly common scene of homeless people passed out in store doorways.

"We were spending a tremendous amount of money and seeing very few results, " said Jordan, now a consultant with the Gordon and Betty Moore Foundation. "... I was reacting to citizens' outcry for help."

Jordan sounded an alarm that still rings today in more conservative circles:

Too many homeless people are drawn to San Francisco because of its generous benefits and lax residency requirements.

Jordan cracked down on camping in parks, panhandling and welfare fraud.

This marked the beginning of an all-out war between San Francisco's mayors and homeless advocates that continues today. The city's liberal Board of Supervisors frequently sided with the advocates, yet voters overwhelmingly backed tough-love policies.

Prentice said he saw a philosophical shift then from trying to solve homelessness to removing the most visible and offensive signs of homelessness off the streets.

"There was no longer any discussion about how to end homelessness," Prentice said. "It's become a management problem."

Smith was free-falling toward rock bottom. After one long bender in a rundown Fillmore hotel room, Smith woke up with sharp pains that felt like a knife twisting in his back. He couldn't breathe. He collapsed on the floor.

Smith said he was left alone for about 12 hours, until a neighbor in the hotel checked on him and called the paramedics. It wasn't Smith's first bout with pneumonia, but it was the worst.

It was 1993 or 1994 -- Smith can't remember. He stayed in the hospital almost three weeks before convincing a friend to give him $8 -- enough to sneak out in his thin hospital gown, in the rain, and find someone to sell him a tiny piece of crack.

After another binge in a friend's hotel room, Smith walked a few blocks to Haight Street before falling asleep. The sounds of morning rush-hour traffic woke him. For the first time, he wondered what he looked like to all those commuters speeding by.

Then Smith caught his reflection in a store window. A stranger's swollen face stared back.

"I almost collapsed right there," he said. "I couldn't believe what I was seeing."

In 1994, voters approved Mayor Jordan'sproposition to ban loitering within 30 feet of an ATM. Months later, they voted to replace a portion of a General Assistance recipient's city welfare checks with a voucher for housing.

But the beginning of the end for Jordan came in midterm when he launched "Matrix" -- a policy that Jordan still says is misunderstood today.

He sent out teams of police, social workers and health aides to approach homeless people on the streets. He thought that at least one worker on each well-rounded team would be able to identify a homeless person's problem and start getting that person some help.

During Matrix's first six months, about 6,000 citations were issued for so- called quality of life misdemeanors such as public inebriation or sleeping in doorways. Homeless activists accused the mayor of criminalizing the poor.

Yet Jordan still insists Matrix was the most sensitive way to find out what each homeless person needed. His only regret is the name Matrix sounds too authoritarian.

After one term, Jordan would be out of office.

With the shock of seeing himself in the shop window, Smith's only thought was getting himself to the Tom Waddell clinic, where he'd seen a counselor regularly since 1989.

The counselor placed Smith at Multi-Service Center North on Polk Street, one of Agnos' shelters. "This was like my final surrender," said Smith.

He spent weeks recuperating but began plotting again how to get high. He met up with an old friend, who had just traded his sneakers for a piece of crack the size of a match head.

Then Smith froze.

"I promised to God when I got to the shelter and all these good things were coming my way, I wouldn't do it again," he said.

Smith was accepted to the Redwood Center in Redwood City for a 90-day residential addiction treatment program with intensive group therapy -- the longest he'd ever completed.

While Mayor Jordan was on his way out, Smith was on his way up.

Willie Brown took over at City Hall in 1996, another new mayor with another new homeless solution. During the campaign, he criticized Jordan's Matrix policy and promised to use his clout as former Assembly speaker to bring in money from the state and federal governments.

Homeless advocates backed Brown after he diligently sought their opinions, which included their ideas about what kind of person should be the city's next homeless czar. But when Brown picked Andy Olshin, a former campaign volunteer and deputy city attorney with no homeless experience, the homeless advocates split with Brown.

They never returned.

The continual bickering eventually led Brown to cancel the city's first homeless summit and announce that homelessness is a problem "that may not be solvable."

"I wasn't misquoted," said Brown, who will leave office in January. "Homelessness is not a city-solvable problem. Homelessness is a societal problem. There can be more organized efforts to provide services . . . but they will not come close to curing homelessness."

Why? Because a real solution with housing and social services takes big money and a federal commitment, he said.

Homeless advocates criticized Brown for retaining some of Jordan's "Matrix" tactics. Brown stepped up police enforcement of anti-camping laws in Golden Gate Park. He remodeled Civic Center Plaza and rousted the homeless who loitered there. The number of police-issued citations for quality-of-life crimes increased.

Meanwhile, resentment between the haves and have-nots intensified during the city's dot-com boom of the late 1990s, when the already costly city became even more out of reach for the poor.

In the midst of the economic success, Brown closed Mission Rock homeless shelter near Pacific Bell Park in 1999 to make room for a parking lot for the new Giants ballpark. His administration retreated from a plan to open a substitute megashelter in the nearby Dogpatch enclave of Potrero Hill when residents and business owners protested.

"Neighborhood people and the merchants and owners of homes and businesses detested the existence of homeless people or street people in close proximity to them," Brown said. ". . . You want to do a shelter? You have no place to locate it."

Brown also stopped expecting much help from state and federal officials on the homeless crisis. And although he pledged to get other Bay Area cities involved in finding a regional solution to homelessness, that didn't pan out, either.

"No one wishes to provide the resources," Brown said. "Only in those cities where (homeless people are highly visible) is there any strong advocacy. . . . What you don't get is a uniform, concentrated, massive resource attack or a change in laws of who can be restrained."

As the economy drooped and tourism dipped, Brown was nagged by the tourist and restaurant industries to do more to keep panhandlers and the homeless off the streets.

But Brown says he can't help people who refuse help -- those who are mentally ill, paranoid about government aid or simply refuse to give up their outdoor lifestyle. Police, district attorneys and court officials must follow the state's strict standards for when to arrest and hospitalize people against their will.

Brown said he underestimated the "irrationality quotient" of the homeless.

"When I came into office I assumed that making services available would and could cause a reversal of the situation for most people on the streets," the mayor said. "I was wrong."

For the first time in his life, Jesse Smith was learning to really look at himself.

After years of therapy, he now realized that he had delusions about how well he survived and how well he was respected on the streets as an addict and dealer. He also began to see the root of his anger, how he expected everyone would disappoint him, starting with his father who abandoned his family.

From Redwood, he graduated to a smaller treatment house in San Francisco, where he stayed for two years after being hired as the program coordinator.

Then he took his current job counseling addicts in the trenches. He works at McMillan Drop-In Center in San Francisco, a place where inebriates walk in or are carried in by police so they can dry out for a few hours.

As for his personal victories, Smith has stuck with rehab and rents a home in Oakland with his girlfriend of seven years and their 3-year-old daughter. He recently went out on medical leave because of an injured back and stress.

Although Smith hasn't forgotten the sweet euphoria after a hit of crack, he'll never forget the terror and shame he felt while standing in the rain, unable to breathe from pneumonia and with nowhere to live.

"My best day loaded," he said, "hasn't been as good as my worst day clean."

Seeing the homeless crisis from the trenches, Smith sounds almost like Willie Brown: "You can be successful at providing services for the homeless population. However, the individual must participate in the services."

After being criticized continually by the advocates and press, Mayor Brown went virtually silent on homelessness during his second term, which started in 2000.

Much of the work he accomplished with the help of his current homeless coordinator, the formerly homeless George Smith, and low-income housing expert Marsha Rosen happened with little fanfare.

The administration funded more than 8,600 units or beds of affordable housing, of which about 3,800 are completed. The city leased and renovated cheap residential hotels and subsidized the rents for homeless folks who have a little income. There are new daytime homeless drop-in centers with lockers and phones. Today, as San Francisco deals with the economic slump and Brown prepares to leave office, the city is left with more homeless people and more hopelessness about the crisis. In October, a homeless street count found the population swelled 18 percent to 8,640 people from the previous year, although homeless advocates say the number is much greater.

Now, after spending millions of taxpayer dollars only to watch the homeless population surge, past mayors and homeless advocates believe the problem is too big for San Francisco to solve without federal intervention.

"Homelessness fell into Feinstein's lap. Every mayor since Feinstein has pretended they are going to fix it," said Boden, one of the city's early homeless organizers. "But no mayor created homelessness, and no mayor is going to solve homelessness."

Feinstein, when asked what she thinks the federal government's role should be, responded: "Sure, everyone wants to pass the buck."

She said she couldn't say whether the federal government should shell out more money because she doesn't know how -- or how well -- San Francisco spends its dollars now.

It will be up to the next mayor, who takes office in January, to look for the answers.. Tomorrow: Where mayoral candidates stand on the homeless issue.