The order of recording doesn't make any difference in pure notice jurisdiction. We will assume that S had not actual notice and there was no reason for inquiry notice (M was not, for example, in possession of Blackacre). Since the lease was not recorded, S took with no notice of M's lease, and is bona fide purchaser for value. Since A took without notice, he is the owner under a notice act. The result would be different under a race or a race/notice act.
This is a really stupid question on my part, but does the protected purchaser get the property or are they just able to sue?