#K49722. Distinct Wall Layers
Distinct Wall Layers
Distinct Wall Layers
You are given k blocks and a target wall layer height h. Each block is described by two integers: its width and height. A block can be used to form a wall layer only if its height exactly equals h. In building the wall layer, blocks with the same width and height are considered identical. Your task is to compute the number of distinct block configurations (i.e. distinct blocks) that can be used to create a wall layer of height h.
In more formal terms, for each block with dimensions (w, hi), if hi = h, it qualifies. You must count the number of distinct values of w among those qualified blocks. If no block qualifies, the answer is 0.
Note: The input parameter k is the number of blocks provided.
The only mathematical relation to note is the equality condition: \[ h_i = h \] for a block to be considered valid.
inputFormat
The first line of the input contains two space-separated integers, k and h, where k is the number of blocks and h is the target height of the wall layer.
This is followed by k lines, each containing two space-separated integers w and hi, representing the width and height of each block respectively.
outputFormat
Output a single integer representing the number of distinct blocks (by width) that have a height equal to h.
## sample3 5
3 5
2 4
1 5
2