#include <bits/stdc++.h>
using namespace std;

int main() 
{
    int n;
    cin>>n;

    string s;
    cin>>s;

    int k;
    cin>>k;

    int i=0; // Left pointer
    int count = 0;
    // store each character and its frequency in the map 
    unordered_map<char,int>mp;
    for(int j=0; j<n; j++) // 'j' Right pointer
    {
        mp[s[j]] = mp[s[j]] + 1; // increment the current character and store its frequency in map

        // If the distint charcter i mean greater than 'k'
        //shrink the window from left
        while(mp.size()>=k) // mp.size() means entire string chi frequency
        {
            mp[s[i]] = mp[s[i]] - 1; // remove that element

            // Remove the character from the map
            // if its frequency becomes zero
            if(mp[s[i]]==0)
            {
                mp.erase(s[i]);
            }

            count = count + (n-j); // then count the substrings
            i++; // move the left pointer ahead 
        }
    }
    cout<<count;
}