### subroutines

def check(pos, k)
  return true if k >= $n
  return false if pos >= $tlen

  for i in (0...$n)
    if ! $used[i] && $ehashs[i][pos]
      $used[i] = true
      tf = check(pos + $elens[i], k + 1)
      $used[i] = false

      return true if tf
    end
  end
  
  false
end

### main

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

  elms = $n.times.map{gets.strip}
  $elens = elms.map{|elm| elm.length}
  #p elms

  text = ''
  m.times.each{text += gets.strip}
  $tlen = text.length
  #p text

  $ehashs = $n.times.map{{}}

  for i in (0...$n)
    elmi = elms[i]
    eleni = $elens[i]
    for j in (0...$tlen)
      $ehashs[i][j] = true if text[j, eleni] == elmi
    end
  end
  #p $ehashs

  $used = $n.times.map{false}
  count = 0
  
  for pos in (0...$tlen)
    count += 1 if check(pos, 0)
  end

  puts count
end