inp = input()
n, q = map(int, inp.split(" "))
books = input()

for i in range(q):
    strlen = int(input())
    qstr = input()
    cnt = 0
    idx = books.find(qstr)
    if idx == -1:
        print(0)
        continue
    cnt += 1
    books = books[:idx] + books[idx+strlen:]

    while True:
        idx = books.find(qstr)
        if idx == -1:
            break
        books = books[:idx] + books[idx+strlen:]
        cnt += 1
    print(cnt)

