include [HTML_REMOVED]
include [HTML_REMOVED]
include [HTML_REMOVED]
using namespace std;
int k;
string s;
char a,b;
int cnt[500010];
int main()
{ cin>>k;
cin>>s;
cin>>a>>b;
long long res=0;
for(int i=0;i<s.size();i)
{
if(s[i]==b)
cnt[i]=cnt[i-1]+1;
else
cnt[i]=cnt[i-1];
}
for(int i=0;i<=s.size()-k+1;i)
{
if(s[i]==a)
res+=cnt[s.size()-1]-cnt[i+k-2];
}
cout<<res;
return 0;
}
类似于滑动窗口 统计下 a+k之后有多少个b就行了