import string int input input int input indices int input for in range

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import string
n = int(input())
s = input()
q = int(input())
indices = [int(input())for i in range(q)]
sort_indices = indices[:]
sort_indices.sort()
counts = dict.fromkeys(string.ascii_lowercase, 0)
ans = dict()
start = 0
i = 0
while i < len(indices) :
print(start, sort_indices[i] - 1)
for c in s[start : sort_indices[i] - 1]:
counts[c] += 1
ans[sort_indices[i]] = counts[s[sort_indices[i] - 1]]
start = sort_indices[i] - 1
i += 1
for ind in indices:
print(ans[ind])