Help! What is happening!? TMI

This has never happened to me before and is scary. I ml not sure if I'm having a terrible period or had a miscarriage. I've been experiencing lots of cramps and terrible back pain. Then a dime size, round, bloody Thing came out as I was trying to have a bowel movement. I felt weird so I looked down to see a long brown stringy discharge being expelled with the red thing attached. I started my period early this morning. Any input would be appreciated. I'm going to see a doctor soon because I've been so worried. Graphic photo!!