#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double EPS = 1e-8;
const ll MOD = 998244353;
const int N = 100000 + 7;
vector<set<char>>seg;
string str;
int q,t,a,b;
char c;
set<char>::iterator it;
void build(int p, int s, int e)
{
if (s == e)
{
seg[p].insert(str[s]);
return;
}
build(p * 2, s, (s + e) / 2);
build(p * 2 + 1, (s + e) / 2 + 1, e);
it=seg[p*2].begin();
for(;it!=seg[p*2].end();it++)
seg[p].insert(*it);
it=seg[p*2+1].begin();
for(;it!=seg[p*2+1].end();it++)
seg[p].insert(*it);
}
void update(int p, int s, int e, int i, char v)
{
if (s == e)
{
seg[p].clear();
seg[p].insert(v);
return;
}
if (i <= (s + e) / 2)
update(p * 2, s, (s + e) / 2, i, v);
else
update(p * 2 + 1, (s + e) / 2 + 1, e, i, v);
seg[p].clear();
it=seg[p*2].begin();
for(;it!=seg[p*2].end();it++)
seg[p].insert(*it);
it=seg[p*2+1].begin();
for(;it!=seg[p*2+1].end();it++)
seg[p].insert(*it);
}
set<char> get(int p, int s, int e, int a, int b)
{
if (s >= a && e <= b)
return seg[p];
if (s > b || e < a)
return set<char>();
set<char>comp;
set<char>st1=get(p * 2, s, (s + e) / 2, a, b),st2=get(p * 2 + 1, (s + e) / 2 + 1, e, a, b);
it=st1.begin();
for(;it!=st1.end();it++)
comp.insert(*it);
it=st2.begin();
for(;it!=st2.end();it++)
comp.insert(*it);
return comp;
}
int main()
{
cin>>str;
scanf("%d", &q);
seg.resize(4 * str.size());
build(1, 0, str.size() - 1);
while(q--)
{
scanf("%d%d",&t,&a);
a--;
if(t==1)
{
scanf(" %c",&c);
update(1,0,str.size()-1,a,c);
}
else
{
scanf("%d",&b);
b--;
printf("%d\n",get(1,0,str.size()-1,a,b).size());
}
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdHlwZWRlZiBsb25nIGxvbmcgbGw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