There are 2 ways of doing that.
First use Reverse:
using (Imap client = new Imap())
{
client.ConnectSSL("imap.example.com");
client.Login("pat@example.com","password");
List<long> uids = client.GetAll();
uids.Reverse();
List<long> newest40 = uids.Take(40).ToList();
client.Close();
}
Second which is a bit tricky as it may download less than 40 elements if some emails were deleted (it should be a tiny bit faster as it doesn't download all uids stored in the folder).
FolderStatus status = client.SelectInbox();
List<long> newest20 = client.Search(
Expression.UID(Range.From(status.UIDNext - 41)));