import java.util.* import java.util.regex.Pattern fun main(args: Array) { val scanner = Scanner(System.`in`) val s = scanner.next() val m = scanner.nextInt() val C = ArrayList() for (i in 0..m - 1) C.add(scanner.next()) scanner.close() var sum = 0 for (pattern in C) { sum += matchNumber(Pattern.compile(pattern), s) } println(sum) } fun matchNumber(pattern: Pattern, target: String): Int { val m = pattern.matcher(target) var count = 0 if (m.find()) { count += 1 while (m.find(m.start() + 1)) count += 1 } return count }