S = gets.chomp M = gets.to_i count = 0 arr = $stdin.read.split("\n") arr.each do |e| i = 0 while i = S.index(e, i) count += 1 i += 1 end end puts count