#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;
if (n == k) {
sort(s.begin(), s.end());
cout << s << "\n";
return 0;
}
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--) {
if (st.size() >= k) {
st.erase({s[j], j});
j--;
}
st.insert({s[i], i});
if (st.size() == k) {
auto it = *st.begin();
if (it.first < s[i]) indx[i] = it.second;
}
}
// for (auto &u : indx) cout << u << " "; cout << endl;
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;
}
}