n, q = map(int, input().split())
word = input()
burners = []
out = []
for i in range(q):
    input()
    burners.append(input())
    out.append(0)

while len(word) > 0:
    for i, burner in enumerate(burners):
        start = 0
        new_word = ""
        while True:
            index = word.find(burner, start)
            if index == -1:
                new_word += word[start:]
                break
            new_word += word[start:index]
            start += index + len(burner)
            out[i] += 1
        word = new_word

for b in out:
    print(b)

