405002: GYM101736 B Badminton

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Badmintontime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

A little green Cactus is secretly in charge of a badminton club, and he wants to enter four members in the next tournament. There is a total of n members in the club. Each member has a playing style and a strength ai. To make the team of four well rounded, Cactus wants at least one member of each playing style on the team. Cactus also wants his team to win the tournament, so he will only consider teams whose strength is at least k. The strength of a team is the average of the strengths of the four individuals.

Cactus wants to know the number of distinct teams of four whose strength is at least k and contains at least one member of each of the three playing styles. Two teams are considered different if there exists a member who is in exactly one of them.

Input

The first line contains two space-separated integers n and k (2 ≤ n ≤ 3000;1 ≤ k ≤ 105), the number of members in the club, and the minimum acceptable team strength respectively.

Each of the next n lines contains two space-separated integers ti and ai (1 ≤ ti ≤ 3;1 ≤ ai ≤ 105), describing the ith member. That is the ith member has playing style ti and strength ai.

Output

Print a single integer representing the number of distinct teams that satisfy the two conditions.

ExampleInput
6 3
1 2
1 2
2 2
3 1
3 3
3 7
Output
5

加入题单

算法标签: