There’s good news for people who need their morning cup of coffee to get through their day. In addition to other health benefits like protecting the liver; boosting metabolism; and reducing the risks of cancer, heart disease, and diabetes, coffee may help teeth by preventing bone loss in the jaw, according to the AGD. Plus, green coffee’s antibacterial properties may help protect the gums.

Some of coffee’s benefits accrue while it is being roasted, said Nasir Bashirelahi, PhD, professor at the University of Maryland School of Dentistry. Its high chlorogenic acid content has antioxidant properties. Also, its polyphenols can prevent cancer and other diseases. It reduces the bad bacteria in the oral microbiome as well.

“Coffee in moderation has many nutritional benefits. Five cups a day should be the limit,” said Bashirelahi. “It is a stimulant, so be sure to stop drinking it early enough so it doesn’t interfere with sleep. For most people, because coffee may help prolong life, the benefits outweigh the risks, such as tooth staining.”

Coffee stains teeth by settling into the tiny holes and ridges in enamel as well as in the resins used in restorations. Still, the AGD suggests several tips for reducing the risks of stained teeth while enjoying some java. For example, coffee can be sipped through a straw to reduce the amount that touches the teeth. Also, drinking or rinsing with water after drinking coffee can reduce the risk of staining.

Most importantly, acidic drinks such as coffee can soften enamel, so brushing your teeth right away can damage it and the dentin underneath it. This effect is temporary, though, and enamel will start to harden again within a half hour of being subjected to acids. The AGD suggests waiting 30 minutes after drinking coffee, wine, lemonade, or other acidic drinks before brushing.