The easier approach would be to consider M and J as one unit.
Now, consider the problem where there are 5 places and 5 ppl to be places in those five places. The number of permutations is 5! = 120. M and j although always beside each other can be arranged among themselves in 2!= 2 ways. So total permutations with M and J beside each other = 120 * 2 = 240.
The answer is:
Reduce 240 from total number of permutations of arranging 6 people on 6 places i.e. 6!=720
i.e. answer is 720-240 =480