n1 = input()
n2 = input()
for i in range(int(input())):
    l, r = list(map(int, input().split()))
    print(n1[l - 1:r].count(n2))

c74f27a5319cc8d314df687efaf04bf4e8fc8f49
<mask token>

<mask token>
for i in range(int(input())):
    l, r = list(map(int, input().split()))
    print(n1[l - 1:r].count(n2))

n1 = input()
n2 = input()
for i in range(int(input())):
    l, r = list(map(int, input().split()))
    print(n1[l - 1:r].count(n2))
