Under construction

Still being built. Things may change

San

Time limit1sMemory limit64 MB

Summary
Count subsets of skyscrapers forming a non-decreasing-height left-to-right jump sequence whose gold sum reaches at least K.
Level

Medium7 of 10

Topics
Dynamic programming, Combinatorics, Sorting
Solved
No attempts yet

Problem

Have you ever dreamt that you were the main character in a computer game? Branimir, the protagonist of this story, is having that dream right now.

The world in Branimir's dream consists of NN skyscrapers lined up from left to right. Skyscraper ii has height HiH_i, and GiG_i gold coins lie on its roof.

The game starts when Branimir jumps onto any one of the skyscrapers, and it continues through a number of steps. In one step Branimir can jump onto a skyscraper that stands to the right of the one he is on and is not lower than it. He may jump over the skyscrapers in between. On every roof he lands on, he collects all the gold coins. He can end the game after any number of steps, zero included, but he must collect at least KK gold coins to advance to the next level.

Count the number of different ways for Branimir to play the game and advance to the next level. Two games are different if some skyscraper is visited in one of them and not in the other.

Input

The first line contains integers NN and KK (1≤N≤401 \le N \le 40, 1≤K≤4×10101 \le K \le 4 \times 10^{10}).

The ii-th of the next NN lines contains integers HiH_i and GiG_i (1≤Hi,Gi≤1091 \le H_i, G_i \le 10^9), describing skyscraper ii.

Output

Print the number of different ways to play the game and advance to the next level.

Hint

In the first example there are three ways to advance. Written as the labels of the visited skyscrapers, they are {1, 2, 3}, {1, 4} and {4}.

Examples3

  1. Example 1

    Input
    4 6
    2 1
    6 3
    7 2
    5 6
    
    Expected output
    3
    
  2. Example 2

    Input
    2 7
    4 6
    3 5
    
    Expected output
    0
    
  3. Example 3

    Input
    4 15
    5 5
    5 12
    6 10
    2 1
    
    Expected output
    4