#include <bits/stdc++.h>
using namespace std;
int len;
string s;
bool check(int i)
{
    if (len - i < 5)
        return false;
    return s[i + 1] == 'l' && s[i + 2] == 'i' && s[i + 3] == 'c' && s[i + 4] == 'e';
}
bool check2(int i)
{
    if (len - i < 3)
        return false;
    return s[i + 1] == 'o' && s[i + 2] == 'b';
}
int main()
{
    int k; //这里绝对不能加关闭流读入，如果这加了getline会直接读不到
    cin >> k;
    getchar();
    getline(cin, s);
    len = s.length();
    vector<int> Alice, Bob;
    for (int i = 0; i < len; i++)
    {
        if (s[i] == 'A' && check(i))
        {
            Alice.push_back(i);
            i += 5;
        }
        else if (s[i] == 'B' && check2(i))
        {
            Bob.push_back(i);
            i += 3;
        }
    }
    int As = Alice.size(), Bs = Bob.size();
    int i = 0, j = 0;
    long long ans = 0;
    for (int q = 0; q < As; q++)
    {
        while (i < Bs && Bob[i] < Alice[q] - k - 3)
            i++; //左边界已经有些被排除的
        while (j < Bs && Bob[j] <= Alice[q] + k + 5)
            j++; //右边界
        ans += j - i;
    }
    cout << ans << "\n";
    return 0;
}
