Even though both bosses (from Company X and Company Y) might have personal and /or management issues, people will definitely have questions in understanding why you were only able to hold the previous two jobs for a short period of time. Please don’t trash the previous bosses during the interviews for new jobs; doing so is not going to do any good to you. I am not sure if you could explain the situation in a much gentle / polite way – it is quite a tough one.