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

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

    int k;
    cin>>k;

    string s;
    cin>>s;

    int count = 0; // count the number of substrings having atleast 'k' Distinct characters

    for(int i=0; i<n; i++)
    {
        unordered_map<char,int>mp; // I have taken a map which will store its distinct characters and its frequency

        for(int j=i; j<n; j++)  // In every sliding window problem if you re entering into for loop or while(j<n) both are same we have to do some calculations
        {
            mp[s[j]] = mp[s[j]] + 1; // increment the map frequency 

            // mp.size means frequency of the character we are checking not only the frequency 
            if(mp.size()>=k)
            {
                int c = n-j;
                count = count + c;
                break;
                
            }
        }
    }

    cout<<count;
}