Consider an ordered list of letters A,B,C...Z. This order represents exactly 1 of the possible permutations of those letters.
Now, if we assign a "High" or "Low" priority to each letter, and move all high priority letters before low priority letters, more orderings are possible. (In this operation, elements of the same priority keep their relational ordering) For example, "Z,A,B,C,D...X,Y" is possible, but "Z,M,A,B,C..." would not be. In fact, in this scenario, there are exactly $2^{26} - 26$ possible permutations.
I obtained this by counting equivalent permutations: ABCD can be generated by both "HHHL" and "LLLL". However, the problem gets much harder with 3 possible priorities (High, Medium, and Low): HHLHH is equivalent to HHLHM as well as HHMHH.
My question is:
Given P priorities, and N distinct elements, how many possible permutations are possible?