n=int(input())
s=list(input())
x=[{ord(c)-ord('a')} for c in s]


def segfunc(x, y):
    return x | y

def init(init_val):
    # set_val
    for i in range(n):
        seg[i+num-1] = init_val[i]
    # built
    for i in range(num-2, -1, -1):
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2])

def update(k, x):
    k += num - 1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[2*k+1], seg[2*k+2])

def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res, seg[p])
        if q&1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res

# identity element
ide_ele = set()

# num: n以上の最小の2のべき乗
num = 2**(n-1).bit_length()
seg = [ide_ele]*2*num

x=init(x)
q=int(input())

for i in range(q):
    t,l,r=input().split()

    if t=='1':
        update(int(l)-1,{ord(r)-ord('a')})
    
    else:
        print(len(query(int(l)-1,int(r)))) n=int(input()) n int(input()) int input() input s=list(input()) s list(input()) list input() input {ord(c)-ord('a')} for c in s for c in s c s for c in s {ord(c)-ord('a')} x=[{ord(c)-ord('a')} for c in s] x [{ord(c)-ord('a')} for c in s] def segfunc(x, y):
    return x | y segfunc return x | y x | y x y x x y y def init(init_val):
    # set_val
    for i in range(n):
        seg[i+num-1] = init_val[i]
    # built
    for i in range(num-2, -1, -1):
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2]) init for i in range(n):
        seg[i+num-1] = init_val[i]
    # built
     i range(n) range n seg[i+num-1] = init_val[i] seg[i+num-1] seg i+num-1 i+num i num 1 init_val[i] init_val i for i in range(num-2, -1, -1):
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2]) i range(num-2, -1, -1) range num-2 num 2 -1 -1 seg[i] = segfunc(seg[2*i+1], seg[2*i+2]) seg[i] seg i segfunc(seg[2*i+1], seg[2*i+2]) segfunc seg[2*i+1] seg 2*i+1 2*i 2 i 1 seg[2*i+2] seg 2*i+2 2*i 2 i 2 init_val init_val def update(k, x):
    k += num - 1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[2*k+1], seg[2*k+2]) update k += num - 1 k num - 1 num 1 seg[k] = x seg[k] seg k x while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[2*k+1], seg[2*k+2]) k k = (k-1)//2 k (k-1)//2 k-1 k 1 2 seg[k] = segfunc(seg[2*k+1], seg[2*k+2]) seg[k] seg k segfunc(seg[2*k+1], seg[2*k+2]) segfunc seg[2*k+1] seg 2*k+1 2*k 2 k 1 seg[2*k+2] seg 2*k+2 2*k 2 k 2 k k x x def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res, seg[p])
        if q&1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res

# identity element query if q <= p:
        return ide_ele
     q <= p q p return ide_ele ide_ele p += num - 1 p num - 1 num 1 q += num - 2 q num - 2 num 2 res = ide_ele res ide_ele while q-p>1:
        if p&1 == 0:
            res = segfunc(res, seg[p])
        if q&1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
     q-p>1 q-p q p 1 if p&1 == 0:
            res = segfunc(res, seg[p])
         p&1 == 0 p&1 p 1 0 res = segfunc(res, seg[p]) res segfunc(res, seg[p]) segfunc res seg[p] seg p if q&1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
         q&1 == 1 q&1 q 1 1 res = segfunc(res, seg[q]) res segfunc(res, seg[q]) segfunc res seg[q] seg q q -= 1 q 1 p = p//2 p p//2 p 2 q = (q-1)//2 q (q-1)//2 q-1 q 1 2 if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
     p == q p q res = segfunc(res, seg[p]) res segfunc(res, seg[p]) segfunc res seg[p] seg p res = segfunc(segfunc(res, seg[p]), seg[q]) res segfunc(segfunc(res, seg[p]), seg[q]) segfunc segfunc(res, seg[p]) segfunc res seg[p] seg p seg[q] seg q return res res p p q q ide_ele = set() ide_ele set() set num = 2**(n-1).bit_length() num 2**(n-1).bit_length() 2 (n-1).bit_length() n-1).bit_length n-1 n 1 bit_length seg = [ide_ele]*2*num seg [ide_ele]*2*num [ide_ele]*2 [ide_ele] ide_ele 2 num x=init(x) x init(x) init x q=int(input()) q int(input()) int input() input for i in range(q):
    t,l,r=input().split()

    if t=='1':
        update(int(l)-1,{ord(r)-ord('a')})
    
    else:
        print(len(query(int(l)-1,int(r)))) i range(q) range q t,l,r=input().split() t input().split() ().split () input split l r if t=='1':
        update(int(l)-1,{ord(r)-ord('a')})
    
    else:
        print(len(query(int(l)-1,int(r)))) t=='1' t '1' update(int(l)-1,{ord(r)-ord('a')}) update int(l)-1 int(l) int l 1 {ord(r)-ord('a')} print(len(query(int(l)-1,int(r)))) print len(query(int(l)-1,int(r))) len query(int(l)-1,int(r)) query int(l)-1 int(l) int l 1 int(r) int r n=int(input()) int(input()) n l,r=input().split() input().split() l ide_ele = set() set() ide_ele t,l,r=input().split() input().split() t num = 2**(n-1).bit_length() 2**(n-1).bit_length() num x=init(x) init(x) x def segfunc(x, y):
    return x | y def segfunc(x, y):
    return x | y segfunc q=int(input()) int(input()) q seg = [ide_ele]*2*num [ide_ele]*2*num seg def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res, seg[p])
        if q&1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res

# identity element def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res, seg[p])
        if q&1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res

# identity element query r=input().split() input().split() r x=[{ord(c)-ord('a')} for c in s] [{ord(c)-ord('a')} for c in s] x def init(init_val):
    # set_val
    for i in range(n):
        seg[i+num-1] = init_val[i]
    # built
    for i in range(num-2, -1, -1):
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2]) def init(init_val):
    # set_val
    for i in range(n):
        seg[i+num-1] = init_val[i]
    # built
    for i in range(num-2, -1, -1):
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2]) init s=list(input()) list(input()) s def update(k, x):
    k += num - 1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[2*k+1], seg[2*k+2]) def update(k, x):
    k += num - 1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[2*k+1], seg[2*k+2]) update
n=int(input())
s=list(input())
x=[{ord(c)-ord('a')} for c in s]


def segfunc(x, y):
    return x | y

def init(init_val):
    # set_val
    for i in range(n):
        seg[i+num-1] = init_val[i]
    # built
    for i in range(num-2, -1, -1):
        seg[i] = segfunc(seg[2*i+1], seg[2*i+2])

def update(k, x):
    k += num - 1
    seg[k] = x
    while k:
        k = (k-1)//2
        seg[k] = segfunc(seg[2*k+1], seg[2*k+2])

def query(p, q):
    if q <= p:
        return ide_ele
    p += num - 1
    q += num - 2
    res = ide_ele
    while q-p>1:
        if p&1 == 0:
            res = segfunc(res, seg[p])
        if q&1 == 1:
            res = segfunc(res, seg[q])
            q -= 1
        p = p//2
        q = (q-1)//2
    if p == q:
        res = segfunc(res, seg[p])
    else:
        res = segfunc(segfunc(res, seg[p]), seg[q])
    return res

# identity element
ide_ele = set()

# num: n以上の最小の2のべき乗
num = 2**(n-1).bit_length()
seg = [ide_ele]*2*num

x=init(x)
q=int(input())

for i in range(q):
    t,l,r=input().split()

    if t=='1':
        update(int(l)-1,{ord(r)-ord('a')})
    
    else:
        print(len(query(int(l)-1,int(r))))