When it comes to the cost of driving, the risks associated with theft and the sheer mind-numbing grind of never-ending, bumper-to-bumper traffic, drivers in Oakland and San Francisco have it especially bad.

The two cities ranked second and fourth, respectively, as the worst cities to drive in the country in a new study. San Jose came in 14th place.

The WalletHub study, released Tuesday, looked at the 100 most populous cities and then evaluated 30 different factors that can increase the pain of getting behind a steering wheel, including cost of ownership and maintenance, traffic congestion, quality of roads and bridges, safety, access to repair shops and the prevalence of stations for non-gas fuel alternatives.

California cities ranked abysmally when it came to the cost of driving. San Francisco came in first for highest gas prices, followed by Oakland. Fremont ranked fourth-worst and San Jose fifth. Bakersfield came in third. And Oakland was dinged for its auto theft rates, coming in second-worst, behind Albuquerque, New Mexico.

San Francisco and Oakland also didn’t fare well when it comes to the overall costs of ownership and maintenance, which in addition to the price of gas included the average cost of a new car, average annual car insurance premiums, maintenance costs, parking rates and lost time and fuel due to traffic-related delays, among other factors. The cities came in fifth and sixth, respectively, with San Jose in 11th place.

The study only confirmed what most drivers traversing Bay Area roadways already know. Tolls, parking, it all adds up, said Adrian S., of San Leandro, who declined to give his last name because he said his company wouldn’t allow it. The Bay Area native bought a house in San Leandro but commutes into San Francisco for work.

“It’s expensive to cross the bridge,” he said. “Parking in the city where I work is crazy high, and traffic is crazy, too.”

A separate study, the Urban Mobility Report, released last month by Texas A&M University’s Transportation Institute, ranked the Bay Area’s commute as the country’s second toughest, beat only by Southern California.

But San Leandro resident Andrea Wavrick thinks the Bay Area is not far behind.

“I would say we are approaching the LA style traffic,” she said. “I definitely think commute times are much worse than they used to be, even though there are so many more options to get to where you’re going.”

Across the country, drivers average 310 hours on the road annually, or about 13 days, according to WalletHub. A separate study by Sky Blue Credit found Bay Area drivers average 11 days annually just getting to and from work — not including taking kids to Little League or going on a road trip through the Sierra. And that adds up to big bucks, the Sky Blue Credit study found, with the average Bay Area resident shelling out about $13,800 on their commute each year.

Related Articles Bay Area traffic delays are second worst in U.S.

Here’s how much time, money you lose commuting in the Bay Area

Why are gas prices so high in California?

20-cent ‘mystery surcharge’ on gas: California lawmakers seek explanation

Gas tax: What Californians actually pay on each gallon of gas Despite the high costs, the Metropolitan Transportation Commission found about two-thirds of Bay Area residents drove alone to work in 2016. In San Francisco, the numbers are much lower, with 38 percent driving alone. In Alameda County, it was 60 percent, compared to 67.5 percent in Contra Costa County, 74.4 percent in Santa Clara County, and 69.4 percent in San Mateo County.

The best way to beat high driving costs, said UC Berkeley Professor Robert Cervero, is simply not to drive. Take public transit, walk or bike whenever possible, he said.

“While gas prices are conspicuous and get noticed in the pocket book, there are many hidden costs tied to owning, using, maintaining, and insuring a car,” Cervero said. “Shedding car ownership and picking and choosing a mobility option among the growing cadre of choices can save substantial amounts of money and help cleanse the planet.”