#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
int n;
string s;
int main()
{
char a, b;
cin >> n >> s >> a >> b;
int k = s.size();
LL ans = 0;
LL res = 0;
for(int i = 0, j = n - 1; j < k; i ++, j ++)
{
if(s[i] == a) ans ++;
if(s[j] == b) res += ans;
}//每个b 前面的a都可以用 所以只需要求每个b前面有几个a就行
cout << res << endl;
return 0;
}