This could just be an adjustment or low fluid, or it could be something more involved like the B2 piston or the Clutch pack.
My tranny did the same thing pretty much only it had lost 4th gear completely.
I would suggest you take it to a Mercedes Transmission specialist, and have them look at it.
In my case, fourth gear was slipping out then would nopt engage at all, my Mechanic opened the Transmission pan to find the clutch pack disintegrated. He of course informed me the Tranny needed to be rebuilt, and of course I had it done.
My situation was a worst case scenario, and probably themost expensive repair.
Hopefully yours will be something other than in need of a rebuild.
The dfirst thing I would do is have your fluid level checked. And Have any adjustments made tot he transmission.
Itmight also be a good idea to have the trans fluid and filter changed if you do not know when it was last done.
I am not a tech, but this is what I have experienced myself and hopefully it will halp you track the problem down.
'92 300CE - Sold
2004 C240 - C7 Wheels
2015 ML350 - P1, Pano, Ash poplar wood, Sport Dinamica interior, Running Boards Keyless go.