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

1
3
2

#pragma GCC optimize(3)
#pragma GCC target("avx,sse2,sse3,sse4,mmx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("inline-functions-called-once")

#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(int)*(tot+1));
		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 p[maxn];
inline void chk(int r){
	if(!tag[r])return;
	tag[r]=0;sam[r].build((r - 1) * B + 1, min(r * B, n));
}
int solve()
{
	int l=read(),r=read();
	scanf("%s",p+1); int Len=strlen(p+1);
	if(Len>200){
		t.build(l,r);
		return t.calc(p,Len);
	}
	int res = 0, Bl = (l - 1) / B + 1, Br = (r - 1) / B + 1;
                                                            				if(Bl == Br) {
                                                            					t.build(l, r);
																				return t.calc(p, Len);
                                                            				}
                                                            				For(i, Bl + 1, Br - 1)chk(i), res += sam[i].calc(p, Len);
                                                            				t.build(l, Bl * B), res += t.calc(p, Len);
                                                            				t.build((Br - 1) * B + 1, r), res += t.calc(p, Len);
                                                            				For(i, Bl + 1, Br) {
                                                            					int pl = max(l, B * (i - 1) - Len + 2), pr = min(B * (i - 1) + Len - 1, r);
                                                            					t.build(pl, pr), res += t.calc(p, 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(),l;
		if(op==1){l=read();int r;
		 scanf("%s", p + 1), s[l] = p[1], r = (l - 1) / B + 1;
            tag[r]=1;
		}
		else printf("%d\n",solve());
	}
    return 0;
}