An IP address consists of 32 bits. For convenience, it is usually written as four bytes, such as 192.168.61.82.
To determine whether two IP addresses belong to the same subnet, a subnet mask is used.
A subnet mask is an IP address where the higher bits are set to 1 and the lower bits are set to 0.
For example, if the first 26 bits are 1 and the remaining 6 bits are 0, the subnet mask is 255.255.255.192.
When two IP addresses are each ANDed with the subnet mask, the result extracts a certain number of higher bits — these bits represent the subnet identifier.
If two addresses have the same identifier, they belong to the same subnet.
Task:
Given a subnet mask, determine whether two IP addresses belong to the same subnet.
Constraints:
If any part of an IP address is N, then 0 ≤ N < 255.
Input:
The first line contains four integers representing the subnet mask.
The second line contains IP address A.
Starting from the third line, there are multiple IP addresses to be checked.
Ex. 255 255 255 0
140 112 28 28
192 169 254 23
140 112 28 8
140 113 28 24
192 168 20 1
234 234 9 34
192 168 20 45
140 112 29 2
140 112 28 88
Output:
Print the number of IP addresses that are in the same subnet as A.
The program must process all input until EOF.
Ex. 2