Since Mail does not have a predefined filter (in Smart Mailboxes) to get the 50 last received messages, I can imagine you could achieve something like this in an AppleScript.
The AppleScript should:
- get every message in Inbox
- sort the list by date
- select all but the most recent 50 ones
- delete selected
Then, create a Mail rule that will be triggered whenever a new email arrives (e.g. you could trigger it on the condition that Recipient contains an "@" or that Sender is not empty), and have the rule execute your AppleScript.
To get you started on how to write an AppleScript that processes Mail messages, see the script you can find in:
/Library/Scripts/Mail Scripts/Rule Actions/Sample Rule Action Script.scpt