#!/bin/python3 import sys import itertools def check(string): bv = 0 for s in string: bv ^= 1 << ord(s) return bv == 0 or bv & (bv - 1) == 0 n,q = input().strip().split(' ') n,q = [int(n),int(q)] s = input().strip() for a0 in range(q): t,i,j = map(int, input().split()) tempS = s[i:(j+1)] count = 0 for L in range(0, len(tempS)+1): for subset in itertools.combinations(tempS, L): if(check(''.join(subset))): count+=1 print (count-1)