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

int main()
{
   string g;
   int n, k;
   cin >> n >> k >> g;

   int count = 0;

   for (int i = 0; i <= n - 1; i++)
   {
      unordered_map<int, int> b;

     for (int j = i; j <= n - 1; j++)
     {
        int number = g[j] - '0';
        b[number] = b[number] + 1;

        // Check whether substring i...j is valid
        int u = 0;

        for (int i = 0; i <= 9; i++)
        {
            if (b[i] == k || b[i] == 0)// means single time you get  frequency of character which is 'k' and '0' then fine 
            {
                // Valid frequency
            }
            else // But if you not get then it is wrong means it is not valid substring 
            {
                u = 1;
                break;
            }
        }

        if (u == 0)
        {
            count = count + 1;
        }
     }
}

cout << count;

    return 0;
}
