#K62717. Eligible Viewers

    ID: 31594 Type: Default 1000ms 256MiB

Eligible Viewers

Eligible Viewers

You are given the number of viewers N and a threshold viewing duration T (in seconds). Each viewer may have watched the content in one or more sessions, where each session is given as a pair of start and end times (in seconds). Your task is to determine how many viewers have accumulated a total viewing duration of at least T seconds.

For each viewer, compute the total watching time by summing up the durations of their sessions, i.e., \[ \text{Total Time} = \sum_{i=1}^{m} (\text{end}_i - \text{start}_i)\] where m is the number of sessions for that viewer. If the total time is at least T, the viewer is considered eligible.

The input will be provided via standard input, and the result should be printed to standard output.

inputFormat

The first line contains two space-separated integers: N (the number of viewers) and T (the threshold duration in seconds).

This is followed by N lines, where each line describes one viewer's sessions. Each of these lines begins with an integer M (the number of sessions for that viewer), followed by 2*M space-separated integers. Each pair of integers represents the start and end times of a session.

For example:

3 1800
2 0 1000 2000 3000
1 0 3600
2 500 1500 1600 2100

indicates there are 3 viewers with threshold 1800 seconds. The first viewer has 2 sessions, the second viewer has 1 session, and the third viewer has 2 sessions.

outputFormat

Output a single integer representing the number of viewers whose total viewing time is at least T seconds.

## sample
3 1800
2 0 1000 2000 3000
1 0 3600
2 500 1500 1600 2100
2