Not sure if this will help in your context but with python you could use the split & join methods...
pth = "c:/aaaa/bbbb/cccc/Project_X/SubFolderY/Some.mxd"
>>> mxdId = pth.split("/")
>>> mxdId
['c:', 'aaaa', 'bbbb', 'cccc', 'Project_X', 'SubFolderY', 'Some.mxd']
>>> mxdId[-3:]
['Project_X', 'SubFolderY', 'Some.mxd']
>>> mxdIdSub = "/".join(mxdId[-3:])
>>> mxdIdSub
'Project_X/SubFolderY/Some.mxd'
>>>
You would have to provide some other logic to identify where you need only the last 2 parts (no sub folder).