### subroutines

def check_rank(favs, nofavs, j, k, l)
  tx, tname = nofavs[k - j]
  sum = 0

  for i in (0...j)
    xi, namei = favs[i]
    diff = tx - xi
    diff += 1 if namei > tname
    sum += diff if diff > 0
  end

  sum <= l
end

### main

loop do
  n, m, k, l = gets.split.map(&:to_i)
  break if (n | m | k | l) == 0

  chrs = []
  for i in (0...n)
    namei, xi = gets.strip.split
    chrs << [xi.to_i, namei]
  end

  fcache = {}
  m.times do
    fcache[gets.strip] = true
  end

  favs = []
  nofavs = []
  for ch in chrs.sort{|a, b| c = (b[0] <=> a[0]); c != 0 ? c : a[1] <=> b[1]}
    if fcache[ch[1]]
      favs << ch
    else
      nofavs << ch
    end
  end
  #p favs
  #p nofavs

  lb = 0
  ub = [m, k].min + 1

  while lb + 1 < ub
    mb = (lb + ub) / 2
    if check_rank(favs, nofavs, mb, k, l)
      lb = mb
    else
      ub = mb
    end
  end

  puts lb
end