### constant

LLEN = 72

### subroutines

def posdel(ary, key)
  i0 = 0
  i1 = ary.length - 1
  loop do
    i = (i0 + i1) / 2
    ai = ary[i]
    if ai == key
      ary.delete_at(i)
      return
    elsif ai > key
      i1 = i - 1
    else
      i0 = i + 1
    end
  end
end

### main

loop do
  line = gets.strip
  break if line == ''

  str = ''
  while line != ''
    str += line
    line = gets.strip
  end
  strlen = str.length
  
  kchs = gets.strip.split('')
  gets

  khash = {}
  kchs.each{|ch| khash[ch] = true}

  kpos = {}
  #p str
  #p khash

  minpos = nil
  minlen = strlen + 1
  minstr = nil
  minc = 0
  rem = kchs.length
  poss = []
  
  for pos in (0...strlen)
    ch = str[pos]
    next if ! khash.key?(ch)

    chpos = kpos[ch]

    if chpos.nil?
      poss << pos
      kpos[ch] = pos
      rem -= 1
    else
      kpos[ch] = pos
      posdel(poss, chpos)
      poss << pos
    end
    #p [pos, ch, minpos]
    
    if rem == 0
      minpos = poss.first
      len = pos - minpos + 1
      if minlen > len
        minlen = len
        minc = 1
        minstr = str[minpos, len]
      elsif minlen == len
        minc += 1
      end
    end
  end

  puts minc
  puts

  if minc > 0
    k = 0
    mslen = minstr.length
    while k < mslen
      puts minstr[k, LLEN]
      k += LLEN
    end
    puts
  end
end