#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
ll n, k; cin >> n >> k;
string s; cin >> s;
ll indx[n];
for (ll i = 0; i < n; i++) indx[i] = i;
ll j = n-1;
set<pair<char, ll>> st;
for (ll i = n-1; i >= 0; i--) {
st.insert({s[i], i});
while (!st.empty() and (*st.begin()).second > i+k-1) st.erase(st.begin());
indx[i] = st.begin()->second;
}
for (ll i = 0; i < n; ) {
if (indx[i] == i) {
cout << s[i];
i++;
continue;
}
string temp;
if (i+k >= n) temp = s.substr(i);
else temp = s.substr(i, k);
sort(temp.begin(), temp.end());
cout << temp;
i += k;
}
}