abcdabcdab
5
2 2 8 ab
2 1 10 ab
1 3 a
1 4 b
2 1 4 ab

1
3
2

#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(register int i=(a);i>=(b);--i)
using namespace std;
inline int read()
{
    char c=getchar();int x=0;bool f=0;
    for(;!isdigit(c);c=getchar())f^=!(c^45);
    for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
    if(f)x=-x;return x;
}
char s[100005];
template<int N>
struct SAM{
	int tot=1,lst=1;
	int ch[N][26],len[N],fa[N],sz[N];
	int newn(){tot++;memset(ch[tot],0,sizeof ch[tot]);return tot;}
	void clear(){tot=0;lst=tot=newn();}
	void append(int c)
	{
		int u=newn(),p=lst;
		len[u]=len[p]+1;sz[u]=1;
		for(;p&&!ch[p][c];p=fa[p])ch[p][c]=u;
		if(!p)fa[u]=1;
		else{
			int q=ch[p][c];
			if(len[q]==len[p]+1)fa[u]=q;
			else{
				int cc=newn();
				fa[cc]=fa[q],len[cc]=len[p]+1;
				memcpy(ch[cc],ch[q],sizeof(ch[cc]));
				for(;p&&ch[p][c]==q;p=fa[p])ch[p][c]=cc;
				fa[q]=fa[u]=cc;
			}
		}lst=u;
	}
	int c[N],b[N];
	inline void radixsort(){
		memset(c,0,sizeof c);
		For(i,1,tot)++c[len[i]];
	    For(i,1,tot)c[i]+=c[i-1];
	    For(i,1,tot)b[c[len[i]]--]=i;
	    Rep(i,tot,2)sz[fa[b[i]]]+=sz[b[i]];
	}
	inline void build(int l,int r){
		clear();
		For(i,l,r)append(s[i]-'a');
		radixsort(); 
	}
	inline int calc(char*s,int len){
		int p=1;
		For(i,1,len){
			p=ch[p][s[i]-'a'];
			if(!p)return 0;
		}return sz[p];
	}
};

#define maxn 100005
const int B=350,T=maxn/B+3;
int n,m,k,bel[maxn],L[maxn],R[maxn];
SAM <B*2>sam[T];
SAM <maxn*2>t;
bool tag[T];
char str[maxn];
int solve()
{
	int l=read(),r=read(),bl=bel[l],br=bel[r],res=0,len;
	scanf("%s",str+1),len=strlen(str+1);
	if(len>200||bl==br)return t.build(l,r),t.calc(str,len);
	t.build(l,R[bl]),res+=t.calc(str,len);
	t.build(L[br],r),res+=t.calc(str,len);
	For(i,bl+1,br-1){
		if(tag[i])tag[i]=0,sam[i].build(L[i],R[i]);
		res+=sam[i].calc(str,len);
	}
	return res;
}

signed main()
{
	scanf("%s",s+1),n=strlen(s+1);
	For(i,1,n)bel[i]=(i-1)/B+1;
	k=bel[n];
	For(i,1,k)L[i]=(i-1)*B+1,R[i]=min(n,i*B),sam[i].build(L[i],R[i]);
	m=read();
	For(_,1,m)
	{
		int op=read(),x;
		if(op==1){
			x=read();char ch;cin>>ch;
			s[x]=ch,tag[bel[x]]=1;
		}
		else printf("%d\n",solve());
	}
    return 0;
}