"use strict";
const main = arg => {
  let word = arg.trim();
  let judge　= "NO";
  let isRoop = true;
  roop:
  while(isRoop){
    switch (word.substr(-3, 3)){
      case 'eam':
        // 5文字分削る
        word = word.slice(0,-5);
        break;
      case 'mer':
        word = word.slice(0,-7);
        break;
      case 'ase':
        word = word.slice(0,-5);
        break;
      case 'ser':
        word = word.slice(0,-6);
        break;
      default:
        isRoop = false;
        break roop;
    }
  }
  if(word.length == 0){
  judge = "YES"
  }
  console.log(judge);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
