from sys import stdin


def main() -> None:
    _, count = map(int, stdin.readline().split(" "))
    word = stdin.readline().strip()

    for _ in range(count):
        stdin.readline()
        seq = stdin.readline().strip()

        matches = word.count(seq)
        print(matches)
        if matches:
            word = word.replace(seq, "")


if __name__ == "__main__":
    main()