Not quite as simple as that sadly (bloody Shimano!)
Medium can deal with 35T overall difference iirc, and long cage up to 45T. Which means, in practice with a 24/38 up front, you’d be limited to an 11-32 cassette. If you wanted to run an 11-36 as most people do, you’re limited to a 10TH difference up front for a medium cage mech.
However… On a hardtail, so no suspension movement to compensate for, I ran 24/36 and an 11-36 with a medium cage XT with no issues at all, giving a 37T difference. I’d only recommend this on a HT though, and even then couldn’t guarantee it will be ok on your exact combo.