Manhattan is packed with thousands of cabs it doesn't need, a new study suggests.

The MIT study, which was published Monday, revealed only 3,000 four-person sedans are needed to serve 98% of ride demands in Manhattan. That's in contrast to the 13,600 taxis and 45,000 for-hire drivers, including Uber and Lyft drivers, that serve greater New York City.

But there's a catch — for this to work, everyone would have to share rides and accept longer trips.

The MIT researchers created a computer formula for pooling passengers headed to similar destinations. Although ridesharing might add wait times and bring some riders out of their way to drop off passengers, the city would benefit from less congestion and pollution.

The study found passengers would have to wait an average of 2.8 minutes and trips would be delayed by an average of 3.5 minutes.

If Manhattan wanted to go even farther to limit traffic, it could adopt 10-passenger vans to serve as taxis -- an effort that could be done with just 2,000 vehicles.

The researchers analyzed a week of Manhattan taxi data from March 2013, including three million rides, to draw their conclusions.

The study is a striking example of the potential around ridesharing. Companies such as Uber and Lyft continue to push the concept, helped along by lowering fares, to customers.

But shared rides haven't been popular with many drivers. Uber drivers have complained UberPool means more work but not necessarily more pay. Some refuse to accept pooled rides. Many riders also avoid shared trips, preferring the comfort and efficiency of not riding with a stranger.

Related: How Uber punishes drivers who refuse to use UberPool

Switching to only shared rides could also impact the livelihood of thousands of drivers. Of the 13,600 New York taxis, roughly 10,000 are in use during peak hours. With only 3,000 shared taxis, most drivers would be left without work. The 45,000 for-hire drivers in the city would also be adversely impacted.

Even if cities and consumers don't gravitate to shared rides today, driving jobs could eventually be eliminated as companies develop self-driving vehicles.