There can only be 20 wolves within 4 blocks of each other.
Example 2:
This shows that there can be no more than 30 villagers withing 40 blocks from each other.
Example 3:
This shows that there can be no more than 30 entities (regardless of type) withing a distance of 2 blocks from each other. However, villagers and dropped items are exempted.