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

for i in range(q):
    strlen = int(input())
    qstr = input()
    cnt = 0

    idx = 0
    idxs = []
    rest = books
    books_new = ""
    while True:
        idx = rest.find(qstr)
        if idx == -1:
            break
        idxs.append(idx)
        cnt += 1
        books_new += rest[:idx]
        rest = rest[idx+strlen:]
    books = books_new + rest



    print(cnt)

