#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long LL;
LL n,cnt,ans;
string s1;
char c1,c2;
int main()
{
// 请在此输入您的代码
cin >> n >> s1 >> c1 >> c2;
for(int i = 0,j = n-1; j < s1.size(); i++,j++)
{
if(s1[i] == c1) cnt ++;
if(s1[j] == c2) ans += cnt;
}
cout << ans;
return 0;
}