#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#include<unordered_map>
#include<unordered_set>
#include<stdio.h>
#include<stdlib.h>
typedef long long ll;
typedef unsigned long long ull;
#define pi 3.1415926535
#define mod 1000000007
// #define mod 99999997 //change when needed
using namespace std;
// using namespace __gnu_pbds;
template <typename T>
T InvMod(T a,T b,T &x,T &y)
{
if(a==0)
{
x=0;
y=1;
return b;
}
T x1,y1;
T g=InvMod(b%a,a,x1,y1);
x=y1-(b/a)*x1;
y=x1;
return g;
}
template <typename T>
T gcd(T a,T b)
{
if(b==0) return a;
return gcd(b,a%b);
}
template <typename T>
ll mod_exp(T a,T b,ll m)
{
if(b==0) return 1;
if(b==1) return a%m;
T tmp=mod_exp(a,b/2,m);
if(b%2==1)
{
return ((tmp%m*tmp%m)%m*a%m)%m;
}
else
{
return (tmp%m*tmp%m)%m;
}
}
//------------------------------------------------------------------------------------------------------------------------------------------------//
struct HASH{
size_t operator()(const pair<ll,ll>&x)const{
return hash<long long>()(((long long)x.first)^(((long long)x.second)<<40));
}
};
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t=1;
// cin>>t;
while(t--)
{
string s;
getline(cin,s);
string p;
getline(cin,p);
int n;
cin>>n;
string tmp=p;
tmp=tmp+'`'+s;
// cout<<tmp<<"\n";
vector<int> z(tmp.length(),0);
int L=0,R=0;
for (int i=1;i<tmp.length();i++)
{
if(i>R)
{
L=R=i;
while(R<tmp.length()&&tmp[R-L]==tmp[R])
{
R++;
}
z[i]=R-L;
R--;
}
else
{
int k=i-L;
if (z[k]<R-i+1)
{
z[i]=z[k];
}
else
{
L=i;
while (R<tmp.length()&&tmp[R-L]==tmp[R])
{
R++;
}
z[i]=R-L;
R--;
}
}
// cout<<z[i]<<" ";
}
int arr[s.length()+1];
memset(arr,0,sizeof arr);
for(int i=p.length()+1;i<tmp.length();i++)
arr[z[i]]++;
// cout<<endl;
int ans=0;
int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gICAgICB0bXA9dG1wKydgJytzOwogICAgICAgIC8vIGNvdXQ8PHRtcDw8IlxuIjsKICAgICAgICB2ZWN0b3I8aW50PiB6KHRtcC5sZW5ndGgoKSwwKTsKICAgICAgICBpbnQgTD0wLFI9MDsKICAgICAgICBmb3IgKGludCBpPTE7aTx0bXAubGVuZ3RoKCk7aSsrKSAKICAgICAgICB7CiAgICAgICAgICAgIGlmKGk+UikgCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIEw9Uj1pOwogICAgICAgICAgICAgICAgd2hpbGUoUjx0bXAubGVuZ3RoKCkmJnRtcFtSLUxdPT10bXBbUl0pIAogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIFIrKzsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHpbaV09Ui1MOyAKICAgICAgICAgICAgICAgIFItLTsKICAgICAgICAgICAgfSAKICAgICAgICAgICAgZWxzZSAKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaW50IGs9aS1MOwogICAgICAgICAgICAgICAgaWYgKHpba108Ui1pKzEpIAogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHpbaV09eltrXTsKICAgICAgICAgICAgICAgIH0gCiAgICAgICAgICAgICAgICBlbHNlIAogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIEw9aTsKICAgICAgICAgICAgICAgICAgICB3aGlsZSAoUjx0bXAubGVuZ3RoKCkmJnRtcFtSLUxdPT10bXBbUl0pIAogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgUisrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB6W2ldPVItTDsgCiAgICAgICAgICAgICAgICAgICAgUi0tOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIC8vIGNvdXQ8PHpbaV08PCIgIjsKICAgICAgICB9CiAgICAgICAgaW50IGFycltzLmxlbmd0aCgpKzFdOwogICAgICAgIG1lbXNldChhcnIsMCxzaXplb2YgYXJyKTsKICAgICAgICBmb3IoaW50IGk9cC5sZW5ndGgoKSsxO2k8dG1wLmxlbmd0aCgpO2krKykKICAgICAgICBhcnJbeltpXV0rKzsKICAgICAgICAvLyBjb3V0PDxlbmRsOwogICAgICAgIGludCBhbnM9MDsKICAgICAgICBpbnQgY250PTA7CiAgICAgICAgZm9yKGludCBpPXMubGVuZ3RoKCk7aT49MDtpLS0pCiAgICAgICAgewogICAgICAgICAgICAvLyBjb3V0PDxpPDwiICI8PGFycltpXTw8IlxuIjsKICAgICAgICAgICAgY250Kz1hcnJbaV07CiAgICAgICAgICAgIGlmKGNudD49bikKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgYW5zPWk7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZihhbnM9PTApCiAgICAgICAgewogICAgICAgICAgICBjb3V0PDwiSU1QT1NTSUJMRVxuIjsKICAgICAgICB9CiAgICAgICAgZWxzZQogICAgICAgIGNvdXQ8PHMuc3Vic3RyKDAsYW5zKTw8IlxuIjsKICAgIH0KfQ==