In this case, all letters are unique.
Start by holding the first letter:
E - XAM
E - XMA
E - MAX
E - MXA
E - AXM
E - AMX
So there are 6 combinations here.
Repeat for all 4 letters.
6 x 4 = 24
This is same as 4x3x2x1.
For 3 unique characters, it is 3x2x1.
For 5 unique characters, it is 5x4x3x2x1
And so on...