A penal colony for finance professionals will soon be holding its annual community service activity with some rules that are considered suitable for a penal colony. Every inmate is assigned a set P of N people to help with their finances and a limit of K minutes. In addition to the circumstances of the jth person, 1 <= j <= N, a time penalty of ej for choosing not to give advice and the time duration of dj minutes allotted to provide the advice are also made clear to the inmate. An inmate starts his community service at time T equal to zero. If the inmate started working with the jth person at time T, then he must terminate his work no later than T+dj. Regardless of the validity of the advice and time of completion, a value of C
j ( = T+ d
j ) is deducted from the inmate's alloted minutes. Also the inmate is not permitted to work with another person until the time T+ d
j. If S is the set of people helped by an inmate, then the total number of used minutes is calculated as
Your task is to write a program to calculate the maximum number of persons that can be helped by an inmate without exceeding his K minutes limit.