Hi,
Each user that will be a member of a dynamic group needs a P1 license or higher. You don't have to assign the licenses, just have enough to cover the total number of unique users that are members. Excerpt:
This feature requires an Azure AD Premium P1 license or Intune for Education for each unique user that is a member of one or more dynamic groups. You don't have to assign licenses to users for them to be members of dynamic groups, but you must have the minimum number of licenses in the Azure AD organization to cover all such users. For example, if you had a total of 1,000 unique users in all dynamic groups in your organization, you would need at least 1,000 licenses for Azure AD Premium P1 to meet the license requirement. No license is required for devices that are members of a dynamic device group.
Source: https://learn.microsoft.com/en-us/azure/active-directory/enterprise-users/groups-dynamic-membership
Enterprise Mobility and Security E5 (EMS E5) includes Azure Active Directory Premium P2 plus many additional features.
Enterprise Mobility + Security pricing options
https://www.microsoft.com/en-us/microsoft-365/enterprise-mobility-security/compare-plans-and-pricing
Here is link to .csv file that has the different products and what is included in each:
NOTE: Having the above .csv can be very helpful once you dig into the different products/features available. Eventually you will need to decide what to buy, and in order to be certain the specific product (AAD P1/P2, EMS E3/E5, M365 Business Premium, M365 Enterprise E3/E5, etc.) you are choosing has all the features at the lowest price you need to know exactly what is in each.
-TP