In Gmail, under IMAP Settings, set Folder Size Limits to number of emails you want it to sync.  By default, its set to no limit.  Then you can control by number how many emails to store in the email client.