#!/usr/bin/ruby
#
# 1032.rb: Course Planning for Lazy Students
#

### main

loop do
  n, u = gets.split.map(&:to_i)
  break if n == 0 && u == 0

  finished = n.times.map{false}
  cis = []
  kis = []
  follows = n.times.map{[]}

  for i in (0...n)
    ci, ki, *ris = gets.split.map(&:to_i)
    cis << ci
    kis << ki

    for ri in ris
      follows[ri] << i
    end
  end

  sumc = 0
  count = 0

  while sumc < u
    max_ci = 0
    max_i = nil

    for i in (0...n)
      if ! finished[i] && kis[i] == 0 && max_ci < cis[i]
        max_ci = cis[i]
        max_i = i
      end
    end
    break if max_i.nil?

    finished[max_i] = true
    sumc += max_ci
    count += 1

    for ri in follows[max_i]
      kis[ri] -= 1
    end
  end

  puts count
end