C++ Code :
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll ;
string s ;
ll r ;
bool check(ll kk){
char yy = s[kk];
ll k = s.size();ll g = 0 ; ll p = 0 ;
while(kk<k && p<r){
p++;
if(s[kk]==yy){
g++;
}
kk++;
}
if(g>=r){
return true ;
}
return false ;
}
int main() {
cin>>r;
cin>>s;
ll gg = 0 ;
while(gg==0){
ll k = s.size();
ll i = 0 ; ll vv = 0 ;
while(i<k){
if(check(i)==true){
string s1 = s.substr(0,i);
ll v = i + r ;
ll l = abs(k-v);
//cout<<v;
//cout<<"\n";
string s2 = s.substr(v,l);
s = s1 + s2 ;
vv = 1 ;
i = 1e18 ;
}
i++;
}
if(vv==1){
} else {
gg = 1 ;
}
}
cout<<s ;
return 0 ;
}