#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <fstream>
#include <string>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <ctime>
#include <sstream>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
typedef pair<ll, ll> llpair;
typedef long double ld;

int N, M, K;
string S;

vector<int> L[26];
set<int> answ;
string anss = "";

void insert(int index)
{
	if (!L[index].size())
		return;

	int inserted = 0;

	for (int pos : L[index])
	{
		auto upp = answ.upper_bound(pos);
		upp--;
		auto low = upp;
		upp++;

		if (*upp - *low > M)
		{
			answ.insert(pos);
			inserted++;
		}
	}

	auto iter = answ.begin();
	auto last = iter;
	iter++;
	for (; iter != answ.end(); ++iter)
	{
		if (*iter - *last > M)
		{
			for (int pos : L[index])
				answ.insert(pos);
			for (int j = 0; j < L[index].size(); ++j)
				anss += 'a' + index;
			return;
		}
		last = iter;
	}

	for (int j = 0; j < inserted; ++j)
		anss += 'a' + index;
	cout << anss << endl;
	exit(0);
}

int main()
{
	ios_base::sync_with_stdio(0);

	cin >> M;
	cin >> S;
	N = S.length();

	answ.insert(0);
	answ.insert(N + 1);

	int i = 1;
	for (char c : S)
		L[c - 'a'].push_back(i++);

	for (int i = 0; i < 26; ++i)
		insert(i);

	return 0;
}


#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <fstream>
#include <string>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <ctime>
#include <sstream>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
typedef pair<ll, ll> llpair;
typedef long double ld;

int N, M, K;
string S;

int main()
{
	ios_base::sync_with_stdio(0);

	cin >> M >> S;
	N = S.length();

	vector<pair<char, int>> A(N);

	for (int i = 0; i < N; ++i)
		A[i] = { S[i], i };

	sort(A.begin(), A.end());
	set<int> ans;

	char lastC;
	int ptr = 0;

	while (true)
	{
		lastC = A[ptr].first;
		while (ptr < N && lastC == A[ptr].first)
		{
			ans.insert(A[ptr].second);
			lastC = A[ptr].first;
			ptr++;
		}

		if (ans.size() > 1)
		{
			auto v1 = ans.begin();
			v1++;
			if (*v1 < M)
			{
				v1--;
				if (S[*v1] == lastC)
					ans.erase(v1);
			}
		}

		if (ans.size() > 1)
		{
			auto v2 = ans.end();
			v2--;
			v2--;
			if (*v2 >= (N - M))
			{
				v2++;
				if (S[*v2] == lastC)
					ans.erase(v2);
			}
		}

		auto v = ans.begin();
		v++;
		for (; ; ++v)
		{
			v--;
			int prv = *v;
			v++;
			if (v == ans.end())
				break;
			v++;
			if (v == ans.end())
				break;
			int nxt = *v;
			v--;

			if (nxt - prv <= M && S[*v] == lastC)
			{
				v = ans.erase(v);
				v--;
			}
		}

		if (*ans.begin() >= M || *ans.rbegin() < (N - M))
			continue;

		v = ans.begin();
		v++;
		bool done = true;
		for (; ; ++v)
		{
			v--;
			int prv = *v;
			v++;
			if (v == ans.end())
				break;
			int cur = *v;
			if (cur - prv > M)
			{
				done = false;
				break;
			}
		}
		if (done)
		{
			string s = "";
			for (int i : ans)
				s += S[i];
			sort(s.begin(), s.end());
			cout << s << endl;
			return 0;
		}
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <fstream>
#include <string>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <ctime>
#include <sstream>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
typedef pair<ll, ll> llpair;
typedef long double ld;

int N, M, K;
string S;

vector<int> L[26];
set<int> answ;
string anss = "";

void insert(int index)
{
	if (!L[index].size())
		return;

	int inserted = 0;

	for (int pos : L[index])
	{
		auto upp = answ.upper_bound(pos);
		upp--;
		auto low = upp;
		upp++;

		if (*upp - *low > M)
		{
			answ.insert(pos);
			inserted++;
		}
	}

	auto last = answ.begin();
	last++;
	auto iter = last;
	last--;
	iter++;
	auto next = iter;
	iter--;

	for (;;++iter)
	{
		iter++;
		next = iter;
		iter--;
		if (next == answ.end())
			break;
		if (*next - *last <= M && S[*iter - 1] - 'a' == index)
		{
			iter = answ.erase(iter);
			iter--;
			inserted--;
		}
		last = iter;
	}

	iter = answ.begin();
	last = iter;
	iter++;
	for (; iter != answ.end(); ++iter)
	{
		if (*iter - *last > M)
		{
			for (int j = 0; j < L[index].size(); ++j)
				anss += 'a' + index;
			return;
		}
		last = iter;
	}

	for (int j = 0; j < inserted; ++j)
		anss += 'a' + index;
	cout << anss << endl;
	exit(0);
}

int main()
{
	ios_base::sync_with_stdio(0);

	cin >> M;
	cin >> S;
	N = S.length();

	answ.insert(0);
	answ.insert(N + 1);

	int i = 1;
	for (char c : S)
		L[c - 'a'].push_back(i++);

	for (i = 0; i < 26; ++i)
		insert(i);

	return 0;
}


#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <fstream>
#include <string>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <ctime>
#include <sstream>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
typedef pair<ll, ll> llpair;
typedef long double ld;

int N, M, K;
string S;

int main()
{
	ios_base::sync_with_stdio(0);

	cin >> M >> S;
	N = S.length();

	vector<pair<char, int>> A(N);

	for (int i = 0; i < N; ++i)
		A[i] = { S[i], i };

	sort(A.begin(), A.end());
	set<int> ans;

	char lastC;
	int ptr = 0;

	while (true)
	{
		lastC = A[ptr].first;
		while (ptr < N && lastC == A[ptr].first)
		{
			ans.insert(A[ptr].second);
			lastC = A[ptr].first;
			ptr++;
		}

		if (ans.size() > 1)
		{
			auto v1 = ans.begin();
			v1++;
			if (*v1 < M)
			{
				v1--;
				if (S[*v1] == lastC)
					ans.erase(v1);
			}
		}

		if (ans.size() > 1)
		{
			auto v2 = ans.end();
			v2--;
			v2--;
			if (*v2 >= (N - M))
			{
				v2++;
				if (S[*v2] == lastC)
					ans.erase(v2);
			}
		}

		auto v = ans.begin();
		v++;
		for (; ; ++v)
		{
			v--;
			int prv = *v;
			v++;
			if (v == ans.end())
				break;
			v++;
			if (v == ans.end())
				break;
			int nxt = *v;
			v--;

			if (nxt - prv <= M && S[*v] == lastC)
				v = ans.erase(v);
		}

		if (*ans.begin() >= M || *ans.rbegin() < (N - M))
			continue;

		v = ans.begin();
		v++;
		bool done = true;
		for (; ; ++v)
		{
			v--;
			int prv = *v;
			v++;
			if (v == ans.end())
				break;
			int cur = *v;
			if (cur - prv > M)
			{
				done = false;
				break;
			}
		}
		if (done)
		{
			string s = "";
			for (int i : ans)
				s += S[i];
			sort(s.begin(), s.end());
			cout << s << endl;
			return 0;
		}
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <fstream>
#include <string>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <ctime>
#include <sstream>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
typedef pair<ll, ll> llpair;
typedef long double ld;

int N, M, K;
string S;

int main()
{
	ios_base::sync_with_stdio(0);

	cin >> M >> S;
	N = S.length();

	vector<pair<char, int>> A(N);

	for (int i = 0; i < N; ++i)
		A[i] = { S[i], i };

	sort(A.begin(), A.end());
	set<int> ans;

	char lastC;
	int ptr = 0;

	while (true)
	{
		lastC = A[ptr].first;
		while (ptr < N && lastC == A[ptr].first)
		{
			ans.insert(A[ptr].second);
			lastC = A[ptr].first;
			ptr++;
		}
		bool er = true;
		while (ans.size() > 1 && er)
		{
			er = false;
			auto v1 = ans.begin();
			v1++;
			if (*v1 < M)
			{
				v1--;
				if (S[*v1] == lastC)
				{
					ans.erase(v1);
					er = true;
				}
			}
		}

		er = true;
		while (ans.size() > 1 && er)
		{
			er = false;
			auto v2 = ans.end();
			v2--;
			v2--;
			if (*v2 >= (N - M))
			{
				v2++;
				if (S[*v2] == lastC)
				{
					ans.erase(v2);
					er = true;
				}
			}
		}

		auto v = ans.begin();
		v++;
		for (; ; ++v)
		{
			v--;
			int prv = *v;
			v++;
			if (v == ans.end())
				break;
			v++;
			if (v == ans.end())
				break;
			int nxt = *v;
			v--;

			if (nxt - prv <= M && S[*v] == lastC)
			{
				v = ans.erase(v);
				v--;
			}
		}

		if (*ans.begin() >= M || *ans.rbegin() < (N - M))
			continue;

		v = ans.begin();
		v++;
		bool done = true;
		for (; ; ++v)
		{
			v--;
			int prv = *v;
			v++;
			if (v == ans.end())
				break;
			int cur = *v;
			if (cur - prv > M)
			{
				done = false;
				break;
			}
		}
		if (done)
		{
			string s = "";
			for (int i : ans)
				s += S[i];
			sort(s.begin(), s.end());
			cout << s << endl;
			return 0;
		}
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <cstring>
#include <set>
#include <map>
#include <fstream>
#include <string>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <ctime>
#include <sstream>
#include <functional>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
typedef pair<ll, ll> llpair;
typedef long double ld;

int N, M, K;
string S;

int main()
{
	ios_base::sync_with_stdio(0);

	cin >> M >> S;
	N = S.length();

	vector<pair<char, int>> A(N);

	for (int i = 0; i < N; ++i)
		A[i] = { S[i], i };

	sort(A.begin(), A.end());
	set<int> ans;

	char lastC;
	int ptr = 0;

	while (true)
	{
		lastC = A[ptr].first;
		while (ptr < N && lastC == A[ptr].first)
		{
			ans.insert(A[ptr].second);
			lastC = A[ptr].first;
			ptr++;
		}
		bool er = true;
		while (ans.size() > 1 && er)
		{
			auto v1 = ans.begin();
			v1++;
			if (*v1 < M)
			{
				v1--;
				if (S[*v1] == lastC)
					ans.erase(v1);
				er = true;
			}
		}

		er = false;
		while (ans.size() > 1 && er)
		{
			auto v2 = ans.end();
			v2--;
			v2--;
			if (*v2 >= (N - M))
			{
				v2++;
				if (S[*v2] == lastC)
					ans.erase(v2);
				er = true;
			}
		}

		auto v = ans.begin();
		v++;
		for (; ; ++v)
		{
			v--;
			int prv = *v;
			v++;
			if (v == ans.end())
				break;
			v++;
			if (v == ans.end())
				break;
			int nxt = *v;
			v--;

			if (nxt - prv <= M && S[*v] == lastC)
			{
				v = ans.erase(v);
				v--;
			}
		}

		if (*ans.begin() >= M || *ans.rbegin() < (N - M))
			continue;

		v = ans.begin();
		v++;
		bool done = true;
		for (; ; ++v)
		{
			v--;
			int prv = *v;
			v++;
			if (v == ans.end())
				break;
			int cur = *v;
			if (cur - prv > M)
			{
				done = false;
				break;
			}
		}
		if (done)
		{
			string s = "";
			for (int i : ans)
				s += S[i];
			sort(s.begin(), s.end());
			cout << s << endl;
			return 0;
		}
	}

	return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct state {
    int f[26] = {};
    bool operator < (const state &other) const {
        for (int i = 0 ;i < 26 ;i++) {
            if (f[i] != other.f[i]) {
                if (f[i] > other.f[i]) {
                    for (int j = i + 1 ;j < 26 ;j++)
                        if (other.f[j])
                            return 1;
                    return 0;
                } else {
                    for (int j = i + 1 ;j < 26 ;j++)
                        if (f[j])
                            return 0;
                    return 1;
                }
            }
        }
        return 0;
    }
};

void print(state x) {
    for (int e : x.f)
        cout << e << ' ';
    cout << endl;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    int m , n;
    string s;
    cin >> m >> s;

    n = s.size();
    for (char &c : s)
        c -= 'a';

    vector<state> v(n + 1);
    v.back() = state();
    map<state , int> mp;
    mp[v.back()]++;

    int sz = 1;

    for (int i = n - 1 ;i >= 0 ;i--) {
        assert(mp.size());
        auto it = mp.begin();
        assert(it->second);
        v[i] = it->first;
        v[i].f[s[i]]++;

        it = next(it);
        if (it != mp.end()) {
            assert(it->second);
            state b = it->first;
            b.f[s[i]]++;
            v[i] = min(v[i] , b);
        }

        sz++;
        mp[v[i]]++;
        if (sz > m) {
            assert(mp[v[i + m]]);
            mp[v[i + m]]--;
            sz--;
            if (!mp[v[i + m]])
                mp.erase(v[i + m]);
        }

//        print(v[i]);
    }

    auto ans = mp.begin()->first;
    for (int i = 0 ;i < 26 ;i++)
        while (ans.f[i]--)
            cout << char(i + 'a');
}


#include <bits/stdc++.h>

using namespace std;

set<int> adj[26];

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    int m;
    string s;
    cin >> m >> s;

    for (int i = 0 ;i < s.size() ;i++)
        adj[s[i] - 'a'].insert(i);

    set<int> sofar;

    auto get = [] (set<int> &st , int l , int r) {
        auto it = st.upper_bound(r);
        if (it == st.begin() || *(it = prev(it)) < l)
            return -1;
        return *it;
    };

    for (int i = 0 ;i < 26 ;i++) {
        bool ok = 1;
        int last = -1;
        while (last + m < s.size()) {
            int x = get(sofar , last + 1 , last + m);
            if (x != -1) {
                last = x;
                continue;
            }

            x = get(adj[i] , last + 1 , last + m);
            if (x == -1) {
                ok = 0;
                for (int x : adj[i])
                    sofar.insert(x);
                break;
            }
            sofar.insert(x);
            last = x;
        }

        if (ok)
            break;
    }

    string ans = "";
    for (int x : sofar)
        ans += s[x];

    sort(ans.begin() , ans.end());
    cout << ans;
}


#include <bits/stdc++.h>

using namespace std;

struct state {
    int f[26] = {};
    bool operator < (const state &other) const {
        for (int i = 0 ;i < 26 ;i++) {
            if (f[i] != other.f[i]) {
                if (f[i] > other.f[i]) {
                    for (int j = i + 1 ;j < 26 ;j++)
                        if (other.f[j])
                            return 1;
                    return 0;
                } else {
                    for (int j = i + 1 ;j < 26 ;j++)
                        if (f[j])
                            return 0;
                    return 1;
                }
            }
        }
        return 0;
    }
};

void print(state x) {
    for (int e : x.f)
        cout << e << ' ';
    cout << endl;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    int m , n;
    string s;
    cin >> m >> s;

    n = s.size();
    for (char &c : s)
        c -= 'a';

    vector<state> v(n + 1);
    v.back() = state();
    map<state , int> mp;
    mp[v.back()]++;
    int sz = 1;

    for (int i = n - 1 ;i >= 0 ;i--) {
        auto it = mp.begin();
        v[i] = it->first;
        v[i].f[s[i]]++;

        it = next(it);
        if (it != mp.end()) {
            state b = it->first;
            b.f[s[i]]++;
            v[i] = min(v[i] , b);
        }

        sz++;
        mp[v[i]]++;
        if (sz > m) {
            mp[v[i + m]]--;
            sz--;
            if (!mp[v[i + m]])
                mp.erase(v[i + m]);

        }

//        print(v[i]);
    }

    auto ans = mp.begin()->first;
    for (int i = 0 ;i < 26 ;i++)
        while (ans.f[i]--)
            cout << char(i + 'a');
}


#include <bits/stdc++.h>

using namespace std;

struct state {
    int f[26] = {};
    bool operator < (const state &other) const {
        for (int i = 0 ;i < 26 ;i++) {
            if (f[i] != other.f[i]) {
                if (f[i] > other.f[i]) {
                    for (int j = i + 1 ;j < 26 ;j++)
                        if (other.f[j])
                            return 1;
                    return 0;
                } else {
                    for (int j = i + 1 ;j < 26 ;j++)
                        if (f[j])
                            return 0;
                    return 1;
                }
            }
        }
        return 0;
    }
};

void print(state x) {
    for (int e : x.f)
        cout << e << ' ';
    cout << endl;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    int m , n;
    string s;
    cin >> m >> s;

    n = s.size();
    for (char &c : s)
        c -= 'a';

    vector<state> v(n + 1);
    v.back() = state();
    map<state , int> mp;
    mp[v.back()]++;

    int sz = 1;

    for (int i = n - 1 ;i >= 0 ;i--) {
        auto it = mp.begin();
        v[i] = it->first;
        v[i].f[s[i]]++;

        for (int j = 0 ;j < 26 ;j++) {
            it = next(it);
            if (it != mp.end()) {
                assert(it->second);
                state b = it->first;
                b.f[s[i]]++;
                v[i] = min(v[i] , b);
            } else {
                break;
            }
        }

        sz++;
        mp[v[i]]++;
        if (sz > m) {
            assert(mp[v[i + m]]);
            mp[v[i + m]]--;
            sz--;
            if (!mp[v[i + m]])
                mp.erase(v[i + m]);
        }

//        cout << i << '\n';
//        print(v[i]);
    }

    auto ans = mp.begin()->first;
    for (int i = 0 ;i < 26 ;i++)
        while (ans.f[i]--)
            cout << char(i + 'a');
}


#include <bits/stdc++.h>

using namespace std;

struct state {
    int f[26] = {};
    bool operator < (const state &other) const {
        for (int i = 0 ;i < 26 ;i++) {
            if (f[i] != other.f[i]) {
                if (f[i] > other.f[i]) {
                    for (int j = i + 1 ;j < 26 ;j++)
                        if (other.f[j])
                            return 1;
                    return 0;
                } else {
                    for (int j = i + 1 ;j < 26 ;j++)
                        if (f[j])
                            return 0;
                    return 1;
                }
            }
        }
        return 0;
    }
};

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.in" , "r" , stdin);
#endif
    int m;
    string s;
    cin >> m >> s;

    for (char &c : s)
        c -= 'a';

    vector<state> v(s.size() + 1);
    v.back() = state();
    map<state , int> mp;
    mp[v.back()]++;
    int sz = 1;

    for (int i = s.size() - 1 ;i >= 0 ;i--) {
        auto it = mp.begin();
        v[i] = it->first;
        v[i].f[s[i]]++;

        if (it != mp.end()) {
            it = next(it);
            state b = it->first;
            b.f[s[i]]++;
            v[i] = min(v[i] , b);
        }

        sz++;
        mp[v[i]]++;
        if (sz > m) {
            mp[v[i + m]]--;
            sz--;
            if (!mp[v[i + m]])
                mp.erase(v[i + m]);
        }
    }

    auto ans = mp.begin()->first;
    for (int i = 0 ;i < 26 ;i++)
        while (ans.f[i]--)
            cout << char(i + 'a');
}


#include<bits/stdc++.h>
#include<stdio.h>

#define pb push_back
#define mp make_pair
#define F first
#define S second

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

const ll INF=2000000000000000001, mod = 1000000007;

int main(){

//ifstream cin("series.in"); ofstream cout("series.out");

//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

string s;
int m; cin >> m >> s;

set<pair<int, int> > M;
set<int> I, I2;
map<int, int> Mn;

for(int i=0; i<s.length(); i++){
    M.insert(mp(-s[i], i));
    Mn[s[i]]++;
    I.insert(i);
    I2.insert(-i);
}

set<pair<int, int> >::iterator rit = M.begin();

while(rit != M.end()){

    pair<int, int> p = *rit; //cout<<(char) -p.F<<" "<<p.S<<" ~ ";

        map<int, int>::iterator itr = Mn.upper_bound(-p.F);
        if(itr->F > -p.F)break;

    int l = -1, r = s.length();

    set<int>::iterator it = I.upper_bound(p.S); if(it!=I.end()) r = *it;
    it = I2.upper_bound(-p.S); if(it!=I2.end()) l = -(*it);

    //cout << l<<" "<<r<<"\n";

    if((l>-1 && r<s.length() && r-l-1 < m) || (l>-1 && l+m >= s.length()) || (r<s.length() && r<=m) ){

        M.erase(p);
        if(Mn[-p.F] > 1) Mn[-p.F]--; else Mn.erase(-p.F);
        I.erase(p.S); I2.erase(-p.S); rit = M.upper_bound(p);
    } else rit++;

}

vector<char> v;

for(set<int>::iterator i = I.begin(); i!=I.end(); i++)
    v.pb(s[(*i)]);

sort(v.begin(), v.end());

for(int i=0; i<v.size(); i++) cout << v[i];

return 0;
}

/* Rovshan Makhsudov - Chessmaster */


#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define F first
#define S second

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

const ll INF=2000000000000000001, mod = 1000000007;

int main(){

//ifstream cin("series.in"); ofstream cout("series.out");

int m; cin >> m;
string s; cin >> s;

map<char, pair<int, int> > M;
set<int> ans;

for(int i=0; i<m; i++){
    M[s[i]].F++;
    M[s[i]].S = i;
}

map<char, pair<int, int> >::iterator it = M.begin();

ans.insert(it->S.S);

for(int i=m; i<s.length(); i++){
    char prev = s[i-m];
    if(M[prev].F>1) M[prev].F--;
    else M.erase(prev);
    M[s[i]].F++;
    M[s[i]].S = i;

    it = M.begin();
    ans.insert(it->S.S);
}

vector<char> v;

for(set<int>::iterator i = ans.begin(); i!=ans.end(); i++)
    v.pb(s[(*i)]);

sort(v.begin(), v.end());

for(int i=0; i<v.size(); i++) cout << v[i];

return 0;
}


#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define F first
#define S second

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

const ll INF=2000000000000000001, mod = 1000000007;

int main(){

//ifstream cin("series.in"); ofstream cout("series.out");

int m; cin >> m;
string s; cin >> s;

set<pair<char, int> > M;
set<int> ans;

for(int i=0; i<m; i++){
    M.insert(mp(s[i], i));

}

set<pair<char, int> >::iterator it = M.begin(), it2;

ans.insert(it->S);

for(int i=m; i<s.length(); i++){
    pair<char, int> prev = mp(s[i-m], -i+m);

    M.insert(mp(s[i], -i)); //cout << prev.S <<" "<<it->S <<"\n";
        if(prev.S == it->S){ //cout <<"yes\n\n";
        M.erase(prev);
        it = M.begin();
        ans.insert( it->S);
        }

    else {
            M.erase(prev);

            it2 = M.begin();
            if(it2->F < it->F){
                it = it2;
                ans.insert( it->S);
            }
    }

}

vector<char> v;

for(set<int>::iterator i = ans.begin(); i!=ans.end(); i++)
    v.pb(s[-(*i)]);

sort(v.begin(), v.end());

for(int i=0; i<v.size(); i++) cout << v[i];

return 0;
}


#include<bits/stdc++.h>
#include<stdio.h>

#define pb push_back
#define mp make_pair
#define F first
#define S second

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

const ll INF=2000000000000000001, mod = 1000000007;

int main(){

//ifstream cin("series.in"); ofstream cout("series.out");

//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

string s;
int m; cin >> m >> s;

set<pair<int, int> > M;
set<int> I, I2;
map<int, int> Mn;

for(int i=0; i<s.length(); i++){
    M.insert(mp(-s[i], i));
    Mn[s[i]]++;
    I.insert(i);
    I2.insert(-i);
}

set<pair<int, int> >::iterator rit = M.begin();

while(rit != M.end()){

    pair<int, int> p = *rit; //cout<<(char) -p.F<<" "<<p.S<<" ~ ";

        map<int, int>::iterator itr = Mn.upper_bound(-p.F);
        if(itr->F > -p.F)break;

    int l = -1, r = s.length();

    set<int>::iterator it = I.upper_bound(r); if(it!=I.end()) r = *it;
    it = I2.upper_bound(-l); if(it!=I2.end()) l = -(*it);

    //cout << l<<" "<<r<<"\n";

    if((l>-1 && r<s.length() && r-l < 2*m) || (l>-1 && l+m-1 < s.length()) || (r<s.length() && r<=m) ){

        M.erase(p);
        if(Mn[-p.F] > 1) Mn[-p.F]--; else Mn.erase(-p.F);
        I.erase(p.S); I2.erase(-p.S); rit = M.upper_bound(p);
    } else rit++;

}

vector<char> v;

for(set<int>::iterator i = I.begin(); i!=I.end(); i++)
    v.pb(s[(*i)]);

sort(v.begin(), v.end());

for(int i=0; i<v.size(); i++) cout << v[i];

return 0;
}

/* Rovshan Makhsudov - Chessmaster */


#include<bits/stdc++.h>
#include<stdio.h>

#define pb push_back
#define mp make_pair
#define F first
#define S second

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

const ll INF=2000000000000000001, mod = 1000000007;

int main(){

//ifstream cin("series.in"); ofstream cout("series.out");

//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

string s;
int m; cin >> m >> s;

set<pair<int, int> > M;
set<int> I, I2;
map<int, int> Mn;

for(int i=0; i<s.length(); i++){
    M.insert(mp(-s[i], i));
    Mn[s[i]]++;
    I.insert(i);
    I2.insert(-i);
}

set<pair<int, int> >::iterator rit = M.begin();

while(rit != M.end()){

if(m==1)break;

    pair<int, int> p = *rit; //cout<<(char) -p.F<<" "<<p.S<<" ~ ";

        map<int, int>::iterator itr = Mn.upper_bound(-p.F);
        if(itr->F > -p.F)break;

    int l = -1, r = s.length();

    set<int>::iterator it = I.upper_bound(p.S); if(it!=I.end()) r = *it;
    it = I2.upper_bound(-p.S); if(it!=I2.end()) l = -(*it);

    //cout << l<<" "<<r<<"\n";

    if((l>-1 && r<s.length() && r-l-1 < m) || (l>-1 && l+m >= s.length()) || (r<s.length() && r<=m) ){

        M.erase(p);
        if(Mn[-p.F] > 1) Mn[-p.F]--; else Mn.erase(-p.F);
        I.erase(p.S); I2.erase(-p.S); rit = M.upper_bound(p);
    } else rit++;

}

vector<char> v;

for(set<int>::iterator i = I.begin(); i!=I.end(); i++)
    v.pb(s[(*i)]);

sort(v.begin(), v.end());

for(int i=0; i<v.size(); i++) cout << v[i];

return 0;
}

/* Rovshan Makhsudov - Chessmaster */


#include<bits/stdc++.h>
#include<stdio.h>

#define pb push_back
#define mp make_pair
#define F first
#define S second

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

const ll INF=2000000000000000001, mod = 1000000007;

int main(){

//ifstream cin("series.in"); ofstream cout("series.out");

//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

string s;
int m; cin >> m >> s;

set<pair<int, int> > M;
set<int> I, I2;
map<int, int> Mn;

for(int i=0; i<s.length(); i++){
    M.insert(mp(-s[i], i));
    Mn[s[i]]++;
    I.insert(i);
    I2.insert(-i);
}

set<pair<int, int> >::iterator rit = M.begin();

while(rit != M.end()){

    pair<int, int> p = *rit; //cout<<(char) -p.F<<" "<<p.S<<" ~ ";

        map<int, int>::iterator itr = Mn.upper_bound(-p.F);
        if(itr->F > -p.F)break;

    int l = 0, r = s.length()-1;

    set<int>::iterator it = I.upper_bound(r); if(it!=I.end()) r = *it;
    it = I2.upper_bound(-l); if(it!=I2.end()) l = -(*it);

    //cout << l<<" "<<r<<"\n";

    if(r-l< 2*m  ){

        M.erase(p);
        if(Mn[-p.F] > 1) Mn[-p.F]--; else Mn.erase(-p.F);
        I.erase(p.S); I2.erase(-p.S); rit = M.upper_bound(p);
    } else rit++;

}

vector<char> v;

for(set<int>::iterator i = I.begin(); i!=I.end(); i++)
    v.pb(s[(*i)]);

sort(v.begin(), v.end());

for(int i=0; i<v.size(); i++) cout << v[i];

return 0;
}

/* Rovshan Makhsudov - Chessmaster */


#include<bits/stdc++.h>
#include<stdio.h>

#define pb push_back
#define mp make_pair
#define F first
#define S second

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

const ll INF=2000000000000000001, mod = 1000000007;

int main(){

//ifstream cin("series.in"); ofstream cout("series.out");

//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

string s;
int m; cin >> m >> s;

set<pair<int, int> > M;
set<int> I, I2;
map<int, int> Mn;

for(int i=0; i<s.length(); i++){
    M.insert(mp(-s[i], i));
    Mn[s[i]]++;
    I.insert(i);
    I2.insert(-i);
}

set<pair<int, int> >::iterator rit = M.begin();

while(rit != M.end()){

//if(m==1)break;

    pair<int, int> p = *rit; //cout<<(char) -p.F<<" "<<p.S<<" ~ ";

        map<int, int>::iterator itr = Mn.upper_bound(-p.F);
        if(itr->F > -p.F)break;

    int l = -1, r = s.length();

    set<int>::iterator it = I.upper_bound(p.S); if(it!=I.end()) r = *it;
    it = I2.upper_bound(-p.S); if(it!=I2.end()) l = -(*it);

    //cout << l<<" "<<r<<"\n";

    if((l>-1 && r<s.length() && r-l-1 < m) || (l>-1 && l+m >= s.length()) || (r<s.length() && r<m) ){

        M.erase(p);
        if(Mn[-p.F] > 1) Mn[-p.F]--; else Mn.erase(-p.F);
        I.erase(p.S); I2.erase(-p.S); rit = M.upper_bound(p);
    } else rit++;

}

vector<char> v;

for(set<int>::iterator i = I.begin(); i!=I.end(); i++)
    v.pb(s[(*i)]);

sort(v.begin(), v.end());

for(int i=0; i<v.size(); i++) cout << v[i];

return 0;
}

/* Rovshan Makhsudov - Chessmaster */


#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define F first
#define S second

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

const ll INF=2000000000000000001, mod = 1000000007;

int main(){

//ifstream cin("series.in"); ofstream cout("series.out");

int m; cin >> m;
string s; cin >> s;

set<pair<char, int> > M;
set<int> ans;

for(int i=0; i<m; i++){
    M.insert(mp(s[i], -i));

}

set<pair<char, int> >::iterator it = M.begin(), it2;

ans.insert(it->S);

for(int i=m; i<s.length(); i++){
    pair<char, int> prev = mp(s[i-m], -i+m);

    M.insert(mp(s[i], -i)); //cout << prev.S <<" "<<it->S <<"\n";
        if(prev.S == it->S){ //cout <<"yes\n\n";
        M.erase(prev);
        it = M.begin();
        ans.insert( it->S);
        }

    else {
            M.erase(prev);

            it2 = M.begin();
            if(it2->F < it->F){
                it = it2;
                ans.insert( it->S);
            }
    }

}

vector<char> v;

for(set<int>::iterator i = ans.begin(); i!=ans.end(); i++)
    v.pb(s[-(*i)]);

sort(v.begin(), v.end());

for(int i=0; i<v.size(); i++) cout << v[i];

return 0;
}


#include<bits/stdc++.h>
#include<stdio.h>

#define pb push_back
#define mp make_pair
#define F first
#define S second

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

const ll INF=2000000000000000001, mod = 1000000007;

int main(){

//ifstream cin("series.in"); ofstream cout("series.out");

//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

string s;
int m; cin >> m >> s;

set<pair<int, int> > M;
set<int> I, I2;
map<int, int> Mn;

for(int i=0; i<s.length(); i++){
    M.insert(mp(-s[i], i));
    Mn[s[i]]++;
    I.insert(i);
    I2.insert(-i);
}

set<pair<int, int> >::iterator rit = M.begin();

while(rit != M.end()){

    pair<int, int> p = *rit; //cout<<(char) -p.F<<" "<<p.S<<" ~ ";

        map<int, int>::iterator itr = Mn.upper_bound(-p.F);
        if(itr->F > -p.F)break;

    int l = -1, r = s.length();

    set<int>::iterator it = I.upper_bound(p.S); if(it!=I.end()) r = *it;
    it = I2.upper_bound(-p.S); if(it!=I2.end()) l = -(*it);

    //cout << l<<" "<<r<<"\n";

    if((l>-1 && r<s.length() && r-l < 2*m-1) || (l>-1 && l+m >= s.length()) || (r<s.length() && r<=m) ){

        M.erase(p);
        if(Mn[-p.F] > 1) Mn[-p.F]--; else Mn.erase(-p.F);
        I.erase(p.S); I2.erase(-p.S); rit = M.upper_bound(p);
    } else rit++;

}

vector<char> v;

for(set<int>::iterator i = I.begin(); i!=I.end(); i++)
    v.pb(s[(*i)]);

sort(v.begin(), v.end());

for(int i=0; i<v.size(); i++) cout << v[i];

return 0;
}

/* Rovshan Makhsudov - Chessmaster */


#include<bits/stdc++.h>
#include<stdio.h>

#define pb push_back
#define mp make_pair
#define F first
#define S second

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

const ll INF=2000000000000000001, mod = 1000000007;

int main(){

//ifstream cin("series.in"); ofstream cout("series.out");

//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

string s;
int m; cin >> m >> s;

set<pair<int, int> > M;
set<int> I, I2;
map<int, int> Mn;

for(int i=0; i<s.length(); i++){
    M.insert(mp(-s[i], i));
    Mn[s[i]]++;
    I.insert(i);
    I2.insert(-i);
}

set<pair<int, int> >::iterator rit = M.begin();

while(rit != M.end()){

    pair<int, int> p = *rit; //cout<<(char) -p.F<<" "<<p.S<<" ~ ";

        map<int, int>::iterator itr = Mn.upper_bound(-p.F);
        if(itr->F > -p.F)break;

    int l = p.S, r = p.S;

    set<int>::iterator it = I.upper_bound(r); if(it!=I.end()) r = *it;
    it = I2.upper_bound(-l); if(it!=I2.end()) l = -(*it);

    //cout << l<<" "<<r<<"\n";

    if(l!=r && ( (r-l < m ) || (r>p.S && l<p.S && r-l<=m) ) ){

        M.erase(p);
        if(Mn[-p.F] > 1) Mn[-p.F]--; else Mn.erase(-p.F);
        I.erase(p.S); I2.erase(-p.S); rit = M.upper_bound(p);
    } else rit++;

}

vector<char> v;

for(set<int>::iterator i = I.begin(); i!=I.end(); i++)
    v.pb(s[(*i)]);

sort(v.begin(), v.end());

for(int i=0; i<v.size(); i++) cout << v[i];

return 0;
}

/* Rovshan Makhsudov - Chessmaster */


#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define F first
#define S second

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

const ll INF=2000000000000000001, mod = 1000000007;

int main(){

//ifstream cin("series.in"); ofstream cout("series.out");

int m; cin >> m;
string s; cin >> s;

set<pair<char, int> > M;
set<int> ans;

for(int i=0; i<m; i++){
    M.insert(mp(s[i], -i));

}

set<pair<char, int> >::iterator it = M.begin();

ans.insert(it->S);

for(int i=m; i<s.length(); i++){
    pair<char, int> prev = mp(s[i-m], -i+m);

    M.insert(mp(s[i], -i)); //cout << prev.S <<" "<<it->S <<"\n";
        if(prev.S == it->S){ //cout <<"yes\n\n";
        M.erase(prev);
        it = M.begin();
        ans.insert( it->S);
        }
    else M.erase(prev);

}

vector<char> v;

for(set<int>::iterator i = ans.begin(); i!=ans.end(); i++)
    v.pb(s[-(*i)]);

sort(v.begin(), v.end());

for(int i=0; i<v.size(); i++) cout << v[i];

return 0;
}


#include<bits/stdc++.h>
#include<stdio.h>

#define pb push_back
#define mp make_pair
#define F first
#define S second

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

const ll INF=2000000000000000001, mod = 1000000007;

int main(){

//ifstream cin("series.in"); ofstream cout("series.out");

//ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

string s;
int m; cin >> m >> s;

set<pair<int, int> > M;
set<int> I, I2;
map<int, int> Mn;

for(int i=0; i<s.length(); i++){
    M.insert(mp(-s[i], i));
    Mn[s[i]]++;
    I.insert(i);
    I2.insert(-i);
}

set<pair<int, int> >::iterator rit = M.begin();

while(rit != M.end()){

    pair<int, int> p = *rit; //cout<<(char) -p.F<<" "<<p.S<<" ~ ";

        map<int, int>::iterator itr = Mn.upper_bound(-p.F);
        if(itr->F > -p.F)break;

    int l = 0, r = s.length()-1;

    set<int>::iterator it = I.upper_bound(r); if(it!=I.end()) r = *it;
    it = I2.upper_bound(-l); if(it!=I2.end()) l = -(*it);

    //cout << l<<" "<<r<<"\n";

    if(l!=r && ( (r-l < m ) || (r>p.S && l<p.S && r-l<=m) ) ){

        M.erase(p);
        if(Mn[-p.F] > 1) Mn[-p.F]--; else Mn.erase(-p.F);
        I.erase(p.S); I2.erase(-p.S); rit = M.upper_bound(p);
    } else rit++;

}

vector<char> v;

for(set<int>::iterator i = I.begin(); i!=I.end(); i++)
    v.pb(s[(*i)]);

sort(v.begin(), v.end());

for(int i=0; i<v.size(); i++) cout << v[i];

return 0;
}

/* Rovshan Makhsudov - Chessmaster */


/*-------property of the half blood prince-----*/

#include <bits/stdc++.h>
#define MIN(X,Y) X<Y?X:Y
#define MAX(X,Y) X>Y?X:Y
#define ISNUM(a) ('0'<=(a) && (a)<='9')
#define ISCAP(a) ('A'<=(a) && (a)<='Z')
#define ISSML(a) ('a'<=(a) && (a)<='z')
#define ISALP(a) (ISCAP(a) || ISSML(a))
#define MXX 10000000000
#define MNN -MXX
#define ISVALID(X,Y,N,M) ((X)>=1 && (X)<=(N) && (Y)>=1 && (Y)<=(M))
#define LLI long long int
#define VI vector<int>
#define VLLI vector<long long int>
#define MII map<int,int>
#define SI set<int>
#define PB push_back
#define MSI map<string,int>
#define PII pair<int,int>
#define FREP(i,I,N) for(int (i)=(I);(i)<=(N);(i)++)
#define eps 0.0000000001
#define RFREP(i,N,I) for(int (i)=(N);(i)>=(I);(i)--)
#define SORTV(VEC) sort(VEC.begin(),VEC.end())
#define SORTVCMP(VEC,cmp) sort(VEC.begin(),VEC.end(),cmp)
#define REVV(VEC) reverse(VEC.begin(),VEC.end())
using namespace std;

int ch[100005];
PII seg[400005]; //first char value, second char pos

void init(int b, int e, int node){
    if(b==e){
        seg[node].first=ch[b];
        seg[node].second=b;
        return;
    }
    if(b>e)return;
    else{
        int lt=node<<1;
        int rt=lt+1;
        int mid=(b+e)>>1;
        init(b,mid,lt);
        init(mid+1,e,rt);
        if(seg[lt].first==seg[rt].first){
            seg[node]=seg[rt];
        }
        else if(seg[lt].first<seg[rt].first){
            seg[node]=seg[lt];
        }
        else{
            seg[node]=seg[rt];
        }
        return;
    }
}

PII query(int i, int j, int b, int e, int node){
    if(b>e)return make_pair(200,-1);
    if(b>=i && e<=j){
        return seg[node];
    }
    if(e<i || b>j){
        return make_pair(200,-1);
    }
    int lt=node<<1;
    int rt=lt+1;
    int mid=(b+e)>>1;
    PII lans=query(i,j,b,mid,lt);
    PII rans=query(i,j,mid+1,e,rt);
    if(lans.first==rans.first){
        int chos=max(lans.second,rans.second);
        return make_pair(lans.first,chos);
    }
    else if(lans.first<rans.first){
        return lans;
    }

    return rans;
}

char s[100005];
int ase[26];
int disi[26];
set<int>pos;
vector<int>ans;
int main(){
    int m;
    scanf("%d",&m);
    scanf("%s",s);
    int l=strlen(s);
    FREP(i,0,25){
        ase[i]=0;
        disi[i]=0;
    }
    FREP(i,0,(l-1)){
        ch[i+1]=s[i];
        ase[s[i]-'a']++;
    }
    init(1,l,1);
    int prevpos,preval;
    for(int i=0;(i+m-1)<l;++i){
        PII q=query(i+1,i+m,1,l,1);
        if(i>=1){
            if(q.first==preval){
                if(prevpos>=(i+1) && prevpos<=(i+m)){
                    q.second=prevpos;
                }
            }
        }
       // cout<<i+1<<" "<<i+m<<" "<<(char)q.first<<" "<<q.second<<"\n";
        pos.insert(q.second);
        prevpos=q.second;
        preval=q.first;
    }
    set<int>::iterator it;
    for(it=pos.begin();it!=pos.end();++it){
        ans.PB(ch[*it]);
    }
    sort(ans.begin(),ans.end());
    int ll=ans.size();
    int prev;
    FREP(i,0,(ll-1)){
        if(i>=1){
            if(ans[i]>prev){
                int dekhte=ans[i]-1;
                int hoise=disi[dekhte-'a'];
                int aro=ase[dekhte-'a']-hoise;
                FREP(i,1,aro){
                    printf("%c",dekhte);
                }
                disi[dekhte-'a']=ase[dekhte-'a'];
            }
        }
        printf("%c",ans[i]);
        disi[ans[i]-'a']++;
        prev=ans[i];
    }
    printf("\n");
    return 0;
}


/*-------property of the half blood prince-----*/

#include <bits/stdc++.h>
#define MIN(X,Y) X<Y?X:Y
#define MAX(X,Y) X>Y?X:Y
#define ISNUM(a) ('0'<=(a) && (a)<='9')
#define ISCAP(a) ('A'<=(a) && (a)<='Z')
#define ISSML(a) ('a'<=(a) && (a)<='z')
#define ISALP(a) (ISCAP(a) || ISSML(a))
#define MXX 10000000000
#define MNN -MXX
#define ISVALID(X,Y,N,M) ((X)>=1 && (X)<=(N) && (Y)>=1 && (Y)<=(M))
#define LLI long long int
#define VI vector<int>
#define VLLI vector<long long int>
#define MII map<int,int>
#define SI set<int>
#define PB push_back
#define MSI map<string,int>
#define PII pair<int,int>
#define FREP(i,I,N) for(int (i)=(I);(i)<=(N);(i)++)
#define eps 0.0000000001
#define RFREP(i,N,I) for(int (i)=(N);(i)>=(I);(i)--)
#define SORTV(VEC) sort(VEC.begin(),VEC.end())
#define SORTVCMP(VEC,cmp) sort(VEC.begin(),VEC.end(),cmp)
#define REVV(VEC) reverse(VEC.begin(),VEC.end())
using namespace std;

int ch[100005];
PII seg[400005]; //first char value, second char pos

void init(int b, int e, int node){
    if(b==e){
        seg[node].first=ch[b];
        seg[node].second=b;
        return;
    }
    if(b>e)return;
    else{
        int lt=node<<1;
        int rt=lt+1;
        int mid=(b+e)>>1;
        init(b,mid,lt);
        init(mid+1,e,rt);
        if(seg[lt].first==seg[rt].first){
            seg[node]=seg[rt];
        }
        else if(seg[lt].first<seg[rt].first){
            seg[node]=seg[lt];
        }
        else{
            seg[node]=seg[rt];
        }
        return;
    }
}

PII query(int i, int j, int b, int e, int node){
    if(b>e)return make_pair(200,-1);
    if(b>=i && e<=j){
        return seg[node];
    }
    if(e<i || b>j){
        return make_pair(200,-1);
    }
    int lt=node<<1;
    int rt=lt+1;
    int mid=(b+e)>>1;
    PII lans=query(i,j,b,mid,lt);
    PII rans=query(i,j,mid+1,e,rt);
    if(lans.first==rans.first){
        int chos=max(lans.second,rans.second);
        return make_pair(lans.first,chos);
    }
    else if(lans.first<rans.first){
        return lans;
    }

    return rans;
}

char s[100005];
int ase[26];
int disi[26];
set<int>pos;
vector<int>ans;
int main(){
    int m;
    scanf("%d",&m);
    scanf("%s",s);
    int l=strlen(s);
    FREP(i,0,25){
        ase[i]=0;
        disi[i]=0;
    }
    FREP(i,0,(l-1)){
        ch[i+1]=s[i];
        ase[s[i]-'0']++;
    }
    init(1,l,1);
    int prevpos,preval;
    for(int i=0;(i+m-1)<l;++i){
        PII q=query(i+1,i+m,1,l,1);
        if(i>=1){
            if(q.first==preval){
                if(prevpos>=(i+1) && prevpos<=(i+m)){
                    q.second=prevpos;
                }
            }
        }
       // cout<<i+1<<" "<<i+m<<" "<<(char)q.first<<" "<<q.second<<"\n";
        pos.insert(q.second);
        prevpos=q.second;
        preval=q.first;
    }
    set<int>::iterator it;
    for(it=pos.begin();it!=pos.end();++it){
        ans.PB(ch[*it]);
    }
    sort(ans.begin(),ans.end());
    int ll=ans.size();
    int prev;
    FREP(i,0,(ll-1)){
        if(i>=1){
            if(ans[i]>prev){
                int dekhte=ans[i]-1;
                int hoise=disi[dekhte-'0'];
                int aro=ase[dekhte-'0']-hoise;
                FREP(i,1,aro){
                    printf("%c",dekhte);
                }
                disi[dekhte-'0']=ase[dekhte-'0'];
            }
        }
        printf("%c",ans[i]);
        disi[ans[i]-'0']++;
        prev=ans[i];
    }
    printf("\n");
    return 0;
}


/*-------property of the half blood prince-----*/

#include <bits/stdc++.h>
#define MIN(X,Y) X<Y?X:Y
#define MAX(X,Y) X>Y?X:Y
#define ISNUM(a) ('0'<=(a) && (a)<='9')
#define ISCAP(a) ('A'<=(a) && (a)<='Z')
#define ISSML(a) ('a'<=(a) && (a)<='z')
#define ISALP(a) (ISCAP(a) || ISSML(a))
#define MXX 10000000000
#define MNN -MXX
#define ISVALID(X,Y,N,M) ((X)>=1 && (X)<=(N) && (Y)>=1 && (Y)<=(M))
#define LLI long long int
#define VI vector<int>
#define VLLI vector<long long int>
#define MII map<int,int>
#define SI set<int>
#define PB push_back
#define MSI map<string,int>
#define PII pair<int,int>
#define FREP(i,I,N) for(int (i)=(I);(i)<=(N);(i)++)
#define eps 0.0000000001
#define RFREP(i,N,I) for(int (i)=(N);(i)>=(I);(i)--)
#define SORTV(VEC) sort(VEC.begin(),VEC.end())
#define SORTVCMP(VEC,cmp) sort(VEC.begin(),VEC.end(),cmp)
#define REVV(VEC) reverse(VEC.begin(),VEC.end())
using namespace std;

int ch[100005];
PII seg[400005]; //first char value, second char pos

void init(int b, int e, int node){
    if(b==e){
        seg[node].first=ch[b];
        seg[node].second=b;
        return;
    }
    if(b>e)return;
    else{
        int lt=node<<1;
        int rt=lt+1;
        int mid=(b+e)>>1;
        init(b,mid,lt);
        init(mid+1,e,rt);
        if(seg[lt].first==seg[rt].first){
            seg[node]=seg[rt];
        }
        else if(seg[lt].first<seg[rt].first){
            seg[node]=seg[lt];
        }
        else{
            seg[node]=seg[rt];
        }
        return;
    }
}

PII query(int i, int j, int b, int e, int node){
    if(b>e)return make_pair(200,-1);
    if(b>=i && e<=j){
        return seg[node];
    }
    if(e<i || b>j){
        return make_pair(200,-1);
    }
    int lt=node<<1;
    int rt=lt+1;
    int mid=(b+e)>>1;
    PII lans=query(i,j,b,mid,lt);
    PII rans=query(i,j,mid+1,e,rt);
    if(lans.first==rans.first){
        int chos=max(lans.second,rans.second);
        return make_pair(lans.first,chos);
    }
    else if(lans.first<rans.first){
        return lans;
    }

    return rans;
}

char s[100005];
int ase[26];
int disi[26];
set<int>pos;
vector<int>ans;
int main(){
    int m;
    scanf("%d",&m);
    scanf("%s",s);
    int l=strlen(s);
    FREP(i,0,25){
        ase[i]=0;
        disi[i]=0;
    }
    FREP(i,0,(l-1)){
        ch[i+1]=s[i];
        ase[s[i]-'a']++;
    }
    init(1,l,1);
    int prevpos,preval;
    for(int i=0;(i+m-1)<l;++i){
        PII q=query(i+1,i+m,1,l,1);
        if(i>=1){
            if(q.first==preval){
                if(prevpos>=(i+1) && prevpos<=(i+m)){
                    q.second=prevpos;
                }
            }
        }
       // cout<<i+1<<" "<<i+m<<" "<<(char)q.first<<" "<<q.second<<"\n";
        pos.insert(q.second);
        prevpos=q.second;
        preval=q.first;
    }
    set<int>::iterator it;
    for(it=pos.begin();it!=pos.end();++it){
        ans.PB(ch[*it]);
    }
    sort(ans.begin(),ans.end());
    int ll=ans.size();
    //int prev;
    int mx=ans[ll-1];
    int cnt=0;
    RFREP(i,(ll-1),0){
        if(ans[i]==mx)cnt++;
        else break;
    }
    FREP(i,0,(mx-'a')-1){
        int nw=ase[i];
        FREP(j,1,nw){
            printf("%c",i+'a');
        }
    }
    FREP(i,1,cnt)printf("%c",mx);
    printf("\n");
    return 0;
}


/*-------property of the half blood prince-----*/

#include <bits/stdc++.h>
#define MIN(X,Y) X<Y?X:Y
#define MAX(X,Y) X>Y?X:Y
#define ISNUM(a) ('0'<=(a) && (a)<='9')
#define ISCAP(a) ('A'<=(a) && (a)<='Z')
#define ISSML(a) ('a'<=(a) && (a)<='z')
#define ISALP(a) (ISCAP(a) || ISSML(a))
#define MXX 10000000000
#define MNN -MXX
#define ISVALID(X,Y,N,M) ((X)>=1 && (X)<=(N) && (Y)>=1 && (Y)<=(M))
#define LLI long long int
#define VI vector<int>
#define VLLI vector<long long int>
#define MII map<int,int>
#define SI set<int>
#define PB push_back
#define MSI map<string,int>
#define PII pair<int,int>
#define FREP(i,I,N) for(int (i)=(I);(i)<=(N);(i)++)
#define eps 0.0000000001
#define RFREP(i,N,I) for(int (i)=(N);(i)>=(I);(i)--)
#define SORTV(VEC) sort(VEC.begin(),VEC.end())
#define SORTVCMP(VEC,cmp) sort(VEC.begin(),VEC.end(),cmp)
#define REVV(VEC) reverse(VEC.begin(),VEC.end())
using namespace std;

int ch[100005];
PII seg[400005]; //first char value, second char pos

void init(int b, int e, int node){
    if(b==e){
        seg[node].first=ch[b];
        seg[node].second=b;
        return;
    }
    if(b>e)return;
    else{
        int lt=node<<1;
        int rt=lt+1;
        int mid=(b+e)>>1;
        init(b,mid,lt);
        init(mid+1,e,rt);
        if(seg[lt].first==seg[rt].first){
            seg[node]=seg[rt];
        }
        else if(seg[lt].first<seg[rt].first){
            seg[node]=seg[lt];
        }
        else{
            seg[node]=seg[rt];
        }
        return;
    }
}

PII query(int i, int j, int b, int e, int node){
    if(b>e)return make_pair(200,-1);
    if(b>=i && e<=j){
        return seg[node];
    }
    if(e<i || b>j){
        return make_pair(200,-1);
    }
    int lt=node<<1;
    int rt=lt+1;
    int mid=(b+e)>>1;
    PII lans=query(i,j,b,mid,lt);
    PII rans=query(i,j,mid+1,e,rt);
    if(lans.first==rans.first){
        int chos=max(lans.second,rans.second);
        return make_pair(lans.first,chos);
    }
    else if(lans.first<rans.first){
        return lans;
    }

    return rans;
}

char s[100005];
int ase[26];
int disi[26];
set<int>pos;
vector<int>ans;
int main(){
    int m;
    scanf("%d",&m);
    scanf("%s",s);
    int l=strlen(s);
    FREP(i,0,(l-1)){
        ch[i+1]=s[i];
        ase[s[i]-'0']++;
    }
    init(1,l,1);
    int prevpos,preval;
    for(int i=0;(i+m-1)<l;++i){
        PII q=query(i+1,i+m,1,l,1);
        if(i>=1){
            if(q.first==preval){
                if(prevpos>=(i+1) && prevpos<=(i+m)){
                    q.second=prevpos;
                }
            }
        }
       // cout<<i+1<<" "<<i+m<<" "<<(char)q.first<<" "<<q.second<<"\n";
        pos.insert(q.second);
        prevpos=q.second;
        preval=q.first;
    }
    set<int>::iterator it;
    for(it=pos.begin();it!=pos.end();++it){
        ans.PB(ch[*it]);
    }
    sort(ans.begin(),ans.end());
    int ll=ans.size();
    int prev;
    FREP(i,0,(ll-1)){
        if(i>=1){
            if(ans[i]>prev){
                int dekhte=ans[i]-1;
                int hoise=disi[dekhte-'0'];
                int aro=ase[dekhte-'0']-hoise;
                FREP(i,1,aro){
                    printf("%c",dekhte);
                }
                disi[dekhte-'0']=ase[dekhte-'0'];
            }
        }
        printf("%c",ans[i]);
        disi[ans[i]-'0']++;
        prev=ans[i];
    }
    printf("\n");
    return 0;
}


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

//#pragma comment (linker, "/STACK:256000000")

typedef long long ll ;

#define endl '\n'
#define  MP make_pair
#define PB push_back
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define fileio freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);
#define boost  ios_base::sync_with_stdio(false);
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
int mod = 1e9 + 7 ;
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b);}
/*---------------------------------------------------------------------------------------------------------------------*/
const int N = 100000 + 5;
int f[N];
string s;
vector<int> p[29];
int n, m;
bool ok() {
	int last = 0;
	for(int i = 0; i < n; i++) {
		if(f[i] != 0) last = 0;
		else last++;
		if(last == m) return false;
	}
	return true;
}
int main() {
	boost; cin.tie(0);cout.tie(0);
	ll i, j, k, l;
	cin >> m;
	cin >> s;
	n = s.length();
	for(i = 0; i < n; i++) {
		p[s[i] - 'a' + 1].PB(i);
	}

	for(i = 1; i < 27; i++) {
		// take all i
		for(j = 0; j < p[i].size(); j++)
			f[p[i][j]] = i;
		if(ok() == false) continue;
		else {
			k = 0;
			l = 0;
			for(j = 0; j < p[i].size(); j++) {
				f[p[i][j]] = 0;
			}
			int last = 0;
			for(j = 0; j < n; j++) {
				if(f[j] != 0) last = 0;
				else last++;
				if(last == m) {
					//cout << j << " \n";
					while(l < p[i].size() && p[i][l] <= j) l++;
					k++;
					last = 0;
				}
			}
			break;
		}
	}
	char ch;
	for(int ii = 1; ii < i; ii++) {
		ch = 'a' + ii - 1;
		for(int jj = 0; jj < p[ii].size(); jj++) cout << ch;
	}
	ch = 'a' + i - 1;
	for(int jj = 0; jj < k; jj++) cout << ch;
	return 0;
}


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

//#pragma comment (linker, "/STACK:256000000")

typedef long long ll ;

#define endl '\n'
#define  MP make_pair
#define PB push_back
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define fileio freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);
#define boost  ios_base::sync_with_stdio(false);
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
int mod = 1e9 + 7 ;
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b);}
/*---------------------------------------------------------------------------------------------------------------------*/
const int N = 100000 + 5;
int f[N];
string s;
vector<int> p[29];
int n, m;
bool ok() {
	int last = 0;
	for(int i = 0; i < n; i++) {
		if(f[i] != 0) last = 0;
		else last++;
		if(last == m) return false;
	}
	return true;
}
int main() {
	boost; cin.tie(0);cout.tie(0);
	ll i, j, k, l;
	cin >> m;
	cin >> s;
	n = s.length();
	for(i = 0; i < n; i++) {
		p[s[i] - 'a' + 1].PB(i);
	}

	for(i = 1; i < 27; i++) {
		// take all i
		for(j = 0; j < p[i].size(); j++)
			f[p[i][j]] = i;
		if(ok() == false) continue;
		else {
			k = 0;
			l = 0;
			for(j = 0; j < p[i].size(); j++) {
				f[p[i][j]] = 0;
			}
			int last = 0;
			for(j = 0; j < n; j++) {
				if(f[j] != 0) last = 0;
				else last++;
				if(last == m) {
					//cout << j << " \n";
					while(l < p[i].size() && p[i][l] <= j + m - 1) l++;
					k++;
					last = 0;
				}
			}
			break;
		}
	}
	char ch;
	for(int ii = 1; ii < i; ii++) {
		ch = 'a' + ii - 1;
		for(int jj = 0; jj < p[ii].size(); jj++) cout << ch;
	}
	ch = 'a' + i - 1;
	for(int jj = 0; jj < k; jj++) cout << ch;
	return 0;
}


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

//#pragma comment (linker, "/STACK:256000000")

typedef long long ll ;

#define endl '\n'
#define  MP make_pair
#define PB push_back
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define fileio freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);
#define boost  ios_base::sync_with_stdio(false);
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
int mod = 1e9 + 7 ;
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b);}
/*---------------------------------------------------------------------------------------------------------------------*/
const int N = 100000 + 5;
int f[N];
string s;
vector<int> p[29];
int n, m;
bool ok() {
	int last = 0;
	for(int i = 0; i < n; i++) {
		if(f[i] != 0) last = 0;
		else last++;
		if(last == m) return false;
	}
	return true;
}
int main() {
	boost; cin.tie(0);cout.tie(0);
	ll i, j, k, l;
	cin >> m;
	cin >> s;
	n = s.length();
	for(i = 0; i < n; i++) {
		p[s[i] - 'a' + 1].PB(i);
	}

	for(i = 1; i < 27; i++) {
		// take all i
		for(j = 0; j < p[i].size(); j++)
			f[p[i][j]] = i;
		if(ok() == false) continue;
		else {
			k = 0;
			l = 0;
			for(j = 0; j < p[i].size(); j++) {
				f[p[i][j]] = 0;
			}
			int last = 0;
			for(j = 0; j < n; j++) {
				if(f[j] != 0) last = 0;
				else last++;
				if(last == m) {
					while(l+1 < p[i].size() && p[i][l+1] <= j) l++;
					k++;
					last = j - p[i][l];
				}
			}
			break;
		}
	}
	char ch;
	for(int ii = 1; ii < i; ii++) {
		ch = 'a' + ii - 1;
		for(int jj = 0; jj < p[ii].size(); jj++) cout << ch;
	}
	ch = 'a' + i - 1;
	for(int jj = 0; jj < k; jj++) cout << ch;
	return 0;
}


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

//#pragma comment (linker, "/STACK:256000000")

typedef long long ll ;

#define endl '\n'
#define  MP make_pair
#define PB push_back
#define F first
#define S second
#define sz(x) ((int)(x).size())
#define rep(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define fileio freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);
#define boost  ios_base::sync_with_stdio(false);
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
int mod = 1e9 + 7 ;
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b);}
/*---------------------------------------------------------------------------------------------------------------------*/
const int N = 100000 + 5;
int f[N];
string s;
vector<int> p[29];
int n, m;
bool ok() {
	int last = 0;
	for(int i = 0; i < n; i++) {
		if(f[i] != 0) last = 0;
		else last++;
		if(last == m) return false;
	}
	return true;
}
int main() {
	boost; cin.tie(0);cout.tie(0);
	ll i, j, k, l;
	cin >> m;
	cin >> s;
	n = s.length();
	for(i = 0; i < n; i++) {
		p[s[i] - 'a' + 1].PB(i);
	}

	for(i = 1; i < 27; i++) {
		// take all i
		for(j = 0; j < p[i].size(); j++)
			f[p[i][j]] = i;
		if(ok() == false) continue;
		else {
			k = 0;
			l = 0;
			for(j = 0; j < p[i].size(); j++) {
				f[p[i][j]] = 0;
			}
			int last = 0;
			for(j = 0; j < n; j++) {
				if(f[j] != 0) last = 0;
				else last++;
				if(last == m) {
					while(l < p[i].size() && p[i][l] <= j) l++;
					k++;
					last = j - p[i][l];
				}
			}
			break;
		}
	}
	char ch;
	for(int ii = 1; ii < i; ii++) {
		ch = 'a' + ii - 1;
		for(int jj = 0; jj < p[ii].size(); jj++) cout << ch;
	}
	ch = 'a' + i - 1;
	for(int jj = 0; jj < k; jj++) cout << ch;
	return 0;
}


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

#define pb push_back
#define rep(i,s,t) for(int i = s; i <= t; ++ i)
const int MaxN = 100050;

int N, M, siz, cnt, pos[MaxN], fa[MaxN];
char str[MaxN];

int f(int x){return fa[x] == x ? x : fa[x] = f(fa[x]);}
void U(int x,int y){fa[f(x)] = f(y);}

int main()
{
	scanf("%d",&M);
	scanf("%s",str+1); N = strlen(str+1);
	rep(i,1,N+1) fa[i] = i;
	rep(i,'a'-'a','z'-'a')
	{
		siz = cnt = 0;
		rep(j,1,N)
			if(str[j] == (char)(i + 'a'))
				pos[++siz] = j;
		pos[++siz] = 1<<30;
		rep(j,1,siz-1)
		{
			int s1 = max(1,pos[j]-M+1), s2 = max(1,pos[j+1]-M+1);
			if(min(min(s2-1,max(1,N-M+1)),pos[j]) >= f(s1))
			{
				for(int k = f(s1); k <= pos[j]; k = f(k))
					U(k,k+1);
				putchar((char)(i + 'a'));
			}
			else ++ cnt;
		}
		if(f(1) == f(max(1,N-M+1)))	break;
		else while(cnt --) putchar((char)(i + 'a'));
	}
	return 0;
}


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

#define pb push_back
#define rep(i,s,t) for(int i = s; i <= t; ++ i)
const int MaxN = 100050;

bool flag;
int N, M, siz, cnt, pos[MaxN], fa[MaxN];
char str[MaxN];

int f(int x){return fa[x] == x ? x : fa[x] = f(fa[x]);}
void U(int x,int y){fa[f(x)] = f(y);}

int main()
{
	scanf("%d",&M);
	scanf("%s",str+1); N = strlen(str+1);
	rep(i,1,N) fa[i] = i;
	rep(i,'a'-'a','z'-'a')
	{
		siz = cnt = 0;
		rep(j,1,N)
			if(str[j] == (char)(i + 'a'))
				pos[++siz] = j;
		pos[++siz] = 1<<30;
		rep(j,1,siz-1)
		{
			flag = false;
			int s1 = max(1,pos[j]-M+1), s2 = max(1,pos[j+1]-M+1);
			for(int k = f(s1); k <= min(min(s2-1,max(1,N-M+1)),pos[j]); k = f(k))
				U(k,k+1), flag = true;
			if(flag) putchar((char)(i+'a'));
			else ++ cnt;
		}
		if(f(1) == f(max(1,N-M+1)))	break;
		else while(cnt --) putchar((char)(i + 'a'));
	}
	return 0;
}


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

#define pb push_back
#define rep(i,s,t) for(int i = s; i <= t; ++ i)
const int MaxN = 100050;

bool flag;
int N, M, siz, cnt, pos[MaxN], fa[MaxN];
char str[MaxN];

int f(int x){return fa[x] == x ? x : fa[x] = f(fa[x]);}
void U(int x,int y){fa[f(x)] = f(y);}

int main()
{
	scanf("%d",&M);
	scanf("%s",str+1); N = strlen(str+1);
	rep(i,1,N) fa[i] = i;
	rep(i,'a'-'a','z'-'a')
	{
		siz = cnt = 0;
		rep(j,1,N)
			if(str[j] == (char)(i + 'a'))
				pos[++siz] = j;
		pos[++siz] = 1<<30;
		rep(j,1,siz-1)
		{
			flag = false;
			int s1 = max(1,pos[j]-M+1), s2 = max(1,pos[j+1]-M+1);
			for(int k = f(s1); k <= min(min(s2-1,max(0,N-M+1)),pos[j]); k = f(k))
				U(k,k+1), flag = true;
			if(flag) ++ cnt;
		}
		while(cnt --) putchar((char)(i + 'a'));
	}
	return 0;
}


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

#define pb push_back
#define rep(i,s,t) for(int i = s; i <= t; ++ i)
const int MaxN = 100050;

int N, M, siz, cnt, pos[MaxN], fa[MaxN];
char str[MaxN];

int f(int x){return fa[x] == x ? x : fa[x] = f(fa[x]);}
void U(int x,int y){fa[f(x)] = f(y);}

int main()
{
	scanf("%d",&M);
	scanf("%s",str+1); N = strlen(str+1);
	rep(i,1,N) fa[i] = i;
	rep(i,'a'-'a','z'-'a')
	{
		siz = cnt = 0;
		rep(j,1,N)
			if(str[j] == (char)(i + 'a'))
				pos[++siz] = j;
		pos[++siz] = 1<<30;
		rep(j,1,siz-1)
		{
			int s1 = max(1,pos[j]-M+1), s2 = max(1,pos[j+1]-M+1);
			if(min(min(s2-1,max(1,N-M+1)))) >= f(s1))
			{
				for(int k = f(s1); k <= pos[j]; k = f(k))
					U(k,k+1);
				putchar((char)(i + 'a'));
			}
			else ++ cnt;
		}
		if(f(1) == f(max(1,N-M+1)))	break;
		else while(cnt --) putchar((char)(i + 'a'));
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
//libs
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <string>
#include <map>
#include <complex>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <queue>

using namespace std;
//defines
#define infll 1e18
#define ll long long
#define itn ll
#define vi vector<itn>
#define vvi vector<vi>
#define pii pair<itn,itn>
//constants
const double eps = 1e-7;
const ll mod = 1000000007;
//end of definition

void solve()
{
	ll n, m,k;
	cin >> n >> m >>k;

	set<pii> a;
	vector<pii> in(k);
	multimap<pii, ll> ma;
	for (ll i = 0; i < k; i++)
	{
		cin >> in[i].first >> in[i].second;
		if (in[i].first >= in[i].second)
		{
			ma.insert({ { in[i].first - in[i].second, 0 }, i });
			ma.insert({ { in[i].first + in[i].second, 0 }, i });
		}
		if (in[i].first >= m - in[i].second)
		{
			ma.insert({ { in[i].first - m + in[i].second, m }, i });
			ma.insert({ { in[i].first + m - in[i].second, m }, i });
		}
		if (in[i].second >= in[i].first)
		{
			ma.insert({ { 0, -in[i].first + in[i].second }, i });
			ma.insert({ { 0, in[i].first + in[i].second }, i });
		}
		if (n - in[i].first <= in[i].second)
		{
			ma.insert({ { n, in[i].first + in[i].second - n }, i });
			ma.insert({ { n, -in[i].first + in[i].second + n }, i });
		}
	}
	ll x=0, y=0;
	ll nx = 1, ny = 1;
	vector<ll> ans(k, infll);
	ll time = 0;
	multimap<pii, ll> rat;
	while (1)
	{
		while (ma.find({ x, y }) != ma.end())
		{
			ll ind = ma.find({ x, y })->second;
			if (ans[ind] != infll)
			{
				ma.erase(ma.find({ x, y }));
				continue;
			}
			pii na = in[ind];
			na.first -= x;
			na.second -= y;
			if (na.first / nx < 0)
			{
				rat.insert({ { x, y }, ind });
			}
			else
			ans[ind] = min(ans[ind], (na.first / nx) + time);
			ma.erase(ma.find({ x, y }));
		}
		while (rat.size())
		{
			ma.insert({ rat.begin()->first, rat.begin()->second });
			rat.erase(rat.begin());
		}

		if (a.find({ x, y }) != a.end())
			break;

		a.insert({ x, y });
		ll nextx = (nx == 1 ? n : 0);
		ll nexty = (ny == 1 ? m : 0);
		ll dx = abs((nextx-x) / nx);
		ll dy = abs((nexty-y) / ny);
		if (dx < dy)
		{
			time += dx;
			x = x + nx*dx;
			y = y + ny*dx;
			nx = -nx;
		}
		if (dx == dy)
			break;
		if (dx > dy)
		{
			time += dy;
			x = x + nx*dy;
			y = y + ny*dy;
			ny = -ny;
		}

	}
	for (ll i : ans)
		cout << (i == infll ? -1:i) << '\n';

}

void solveD()
{
	int k; cin >> k;
	multiset < char > a;
	string s;
	cin >> s;
	for (int i = 0; i < s.size();)
	{
		unsigned char q = 255;
		int pl = 0;

		for (int j = 0; j < k && i+j<s.size(); j++)
		{
			if (q>=s[i + j])
			{
				q = s[i + j];
				pl = i + j;
			}
		}
		if (i + k > s.size())
		{
			break;
		}
		else
		a.insert(q);
		i = pl+1;
	}
	char maxq;
	auto qw = a.end();
	qw--;
	maxq = *qw;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] < maxq)
			a.insert(s[i]);
	}
	for (auto i : a)
		cout << i;
	cout << endl;

}

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(0); cout.tie(0);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("input.txt", "w", stdout);
#endif
	solveD();

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
//libs
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <string>
#include <map>
#include <complex>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <queue>

using namespace std;
//defines
#define infll 1e18
#define ll long long
#define itn ll
#define vi vector<itn>
#define vvi vector<vi>
#define pii pair<itn,itn>
//constants
const double eps = 1e-7;
const ll mod = 1000000007;
//end of definition

void solve()
{
	ll n, m,k;
	cin >> n >> m >>k;

	set<pii> a;
	vector<pii> in(k);
	multimap<pii, ll> ma;
	for (ll i = 0; i < k; i++)
	{
		cin >> in[i].first >> in[i].second;
		if (in[i].first >= in[i].second)
		{
			ma.insert({ { in[i].first - in[i].second, 0 }, i });
			ma.insert({ { in[i].first + in[i].second, 0 }, i });
		}
		if (in[i].first >= m - in[i].second)
		{
			ma.insert({ { in[i].first - m + in[i].second, m }, i });
			ma.insert({ { in[i].first + m - in[i].second, m }, i });
		}
		if (in[i].second >= in[i].first)
		{
			ma.insert({ { 0, -in[i].first + in[i].second }, i });
			ma.insert({ { 0, in[i].first + in[i].second }, i });
		}
		if (n - in[i].first <= in[i].second)
		{
			ma.insert({ { n, in[i].first + in[i].second - n }, i });
			ma.insert({ { n, -in[i].first + in[i].second + n }, i });
		}
	}
	ll x=0, y=0;
	ll nx = 1, ny = 1;
	vector<ll> ans(k, infll);
	ll time = 0;
	multimap<pii, ll> rat;
	while (1)
	{
		while (ma.find({ x, y }) != ma.end())
		{
			ll ind = ma.find({ x, y })->second;
			if (ans[ind] != infll)
			{
				ma.erase(ma.find({ x, y }));
				continue;
			}
			pii na = in[ind];
			na.first -= x;
			na.second -= y;
			if (na.first / nx < 0)
			{
				rat.insert({ { x, y }, ind });
			}
			else
			ans[ind] = min(ans[ind], (na.first / nx) + time);
			ma.erase(ma.find({ x, y }));
		}
		while (rat.size())
		{
			ma.insert({ rat.begin()->first, rat.begin()->second });
			rat.erase(rat.begin());
		}

		if (a.find({ x, y }) != a.end())
			break;

		a.insert({ x, y });
		ll nextx = (nx == 1 ? n : 0);
		ll nexty = (ny == 1 ? m : 0);
		ll dx = abs((nextx-x) / nx);
		ll dy = abs((nexty-y) / ny);
		if (dx < dy)
		{
			time += dx;
			x = x + nx*dx;
			y = y + ny*dx;
			nx = -nx;
		}
		if (dx == dy)
			break;
		if (dx > dy)
		{
			time += dy;
			x = x + nx*dy;
			y = y + ny*dy;
			ny = -ny;
		}

	}
	for (ll i : ans)
		cout << (i == infll ? -1:i) << '\n';

}

void solveD()
{
	int k; cin >> k;
	multiset < char > a;
	string s;
	cin >> s;
	for (int i = 0; i < s.size();)
	{
		unsigned char q = 255;
		int pl = 0;
		auto qw = a.end();
		if (a.size())qw--;
		char q1 = 0;
		if (a.size())
			q1 = *qw;
		for (int j = 0; j < k && i+j<s.size(); j++)
		{
			if (q>s[i + j])
			{
				q = s[i + j];
				pl = i + j;
			}
			if (q == s[i + j] && q < q1)
			{
				q = s[i + j];
				pl = i + j;
			}
		}
		if (i + k > s.size())
		{
			auto qw = a.end(); qw--;
			char q1 = *qw;
			if (q1 > q)
				a.insert(q);
			else
				break;
		}
		else
		a.insert(q);
		i = pl+1;

	}
	for (auto i : a)
		cout << i;
	cout << endl;

}

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(0); cout.tie(0);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("input.txt", "w", stdout);
#endif
	solveD();

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
//libs
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <string>
#include <map>
#include <complex>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <queue>

using namespace std;
//defines
#define infll 1e18
#define ll long long
#define itn ll
#define vi vector<itn>
#define vvi vector<vi>
#define pii pair<itn,itn>
//constants
const double eps = 1e-7;
const ll mod = 1000000007;
//end of definition

void solve()
{
	ll n, m,k;
	cin >> n >> m >>k;

	set<pii> a;
	vector<pii> in(k);
	multimap<pii, ll> ma;
	for (ll i = 0; i < k; i++)
	{
		cin >> in[i].first >> in[i].second;
		if (in[i].first >= in[i].second)
		{
			ma.insert({ { in[i].first - in[i].second, 0 }, i });
			ma.insert({ { in[i].first + in[i].second, 0 }, i });
		}
		if (in[i].first >= m - in[i].second)
		{
			ma.insert({ { in[i].first - m + in[i].second, m }, i });
			ma.insert({ { in[i].first + m - in[i].second, m }, i });
		}
		if (in[i].second >= in[i].first)
		{
			ma.insert({ { 0, -in[i].first + in[i].second }, i });
			ma.insert({ { 0, in[i].first + in[i].second }, i });
		}
		if (n - in[i].first <= in[i].second)
		{
			ma.insert({ { n, in[i].first + in[i].second - n }, i });
			ma.insert({ { n, -in[i].first + in[i].second + n }, i });
		}
	}
	ll x=0, y=0;
	ll nx = 1, ny = 1;
	vector<ll> ans(k, infll);
	ll time = 0;
	multimap<pii, ll> rat;
	while (1)
	{
		while (ma.find({ x, y }) != ma.end())
		{
			ll ind = ma.find({ x, y })->second;
			if (ans[ind] != infll)
			{
				ma.erase(ma.find({ x, y }));
				continue;
			}
			pii na = in[ind];
			na.first -= x;
			na.second -= y;
			if (na.first / nx < 0)
			{
				rat.insert({ { x, y }, ind });
			}
			else
			ans[ind] = min(ans[ind], (na.first / nx) + time);
			ma.erase(ma.find({ x, y }));
		}
		while (rat.size())
		{
			ma.insert({ rat.begin()->first, rat.begin()->second });
			rat.erase(rat.begin());
		}

		if (a.find({ x, y }) != a.end())
			break;

		a.insert({ x, y });
		ll nextx = (nx == 1 ? n : 0);
		ll nexty = (ny == 1 ? m : 0);
		ll dx = abs((nextx-x) / nx);
		ll dy = abs((nexty-y) / ny);
		if (dx < dy)
		{
			time += dx;
			x = x + nx*dx;
			y = y + ny*dx;
			nx = -nx;
		}
		if (dx == dy)
			break;
		if (dx > dy)
		{
			time += dy;
			x = x + nx*dy;
			y = y + ny*dy;
			ny = -ny;
		}

	}
	for (ll i : ans)
		cout << (i == infll ? -1:i) << '\n';

}

void solveD()
{
	int k; cin >> k;
	multiset < char > a;
	string s;
	cin >> s;
	set<int> u;
	for (int i = 0; i < s.size();)
	{
		unsigned char q = 255;
		int pl = 0;

		for (int j = 0; j < k && i+j<s.size(); j++)
		{
			if (q>=s[i + j])
			{
				q = s[i + j];
				pl = i + j;
			}
		}
		if (i + k > s.size())
		{
			break;
		}
		else
		a.insert(q);
		u.insert(pl);
		i = pl+1;
	}
	char maxq;
	auto qw = a.end();
	qw--;
	maxq = *qw;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] < maxq && u.find(i)==u.end())
			a.insert(s[i]);
	}
	for (auto i : a)
		cout << i;
	cout << endl;

}

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(0); cout.tie(0);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("input.txt", "w", stdout);
#endif
	solveD();

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
//libs
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <string>
#include <map>
#include <complex>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <queue>

using namespace std;
//defines
#define infll 1e18
#define ll long long
#define itn ll
#define vi vector<itn>
#define vvi vector<vi>
#define pii pair<itn,itn>
//constants
const double eps = 1e-7;
const ll mod = 1000000007;
//end of definition

void solve()
{
	ll n, m,k;
	cin >> n >> m >>k;

	vvi a(4, vi(max(n, m), 0));
	//a[0][0] = 1;
	vector<pii> in(k);
	multimap<pii, ll> ma;
	for (ll i = 0; i < k; i++)
	{
		cin >> in[i].first >> in[i].second;
		if (in[i].first >= in[i].second)
		{
			ma.insert({ { in[i].first - in[i].second, 0 }, i });
			ma.insert({ { in[i].first + in[i].second, 0 }, i });
		}
		if (in[i].first >= m - in[i].second)
		{
			ma.insert({ { in[i].first - m + in[i].second, m }, i });
			ma.insert({ { in[i].first + m - in[i].second, m }, i });

		}
		if (in[i].second >= in[i].first)
		{
			ma.insert({ { 0, -in[i].first + in[i].second }, i });
			ma.insert({ { 0, in[i].first + in[i].second }, i });
		}
		if (n - in[i].first <= in[i].second)
		{
			ma.insert({ { n, in[i].first + in[i].second - n }, i });
			ma.insert({ { n, -in[i].first + in[i].second + n }, i });

		}
	}
	ll x=0, y=0;
	ll nx = 1, ny = 1;
	vector<ll> ans(k, infll);
	ll time = 0;
	multimap<pii, ll> rat;
	while (1)
	{
		while (ma.find({ x, y }) != ma.end())
		{
			ll ind = ma.find({ x, y })->second;
			pii na = in[ind];
			na.first -= x;
			na.second -= y;
			if (na.first / nx < 0)
			{
				rat.insert({ { x, y }, ind });
			}
			else
			ans[ind] = min(ans[ind], (ll)na.first / nx +time);
			ma.erase(ma.find({ x, y }));
		}
		while (rat.size())
		{
			ma.insert({ rat.begin()->first, rat.begin()->second });
			rat.erase(rat.begin());
		}
		ll teku = 0, teku1;
		if (x == 0)
		{
			teku = 3;
			teku1 = y;
		}
		if (x == n)
		{
			teku = 1;
			teku1 = y;
		}
		if (y == 0)
		{
			teku = 0;
			teku1 = x;
		}
		if (y == m)
		{
			teku = 2;
			teku1 = x;
		}
		if (a[teku][teku1] == 1)
			break;
		a[teku][teku1] = 1;
		ll nextx = (nx == 1 ? n : 0);
		ll nexty = (ny == 1 ? m : 0);
		ll dx = abs((nextx-x) / nx);
		ll dy = abs((nexty-y) / ny);
		if (dx < dy)
		{
			time += dx;
			x = x + nx*dx;
			y = y + ny*dx;
			nx = -nx;
		}
		if (dx == dy)
			break;
		if (dx > dy)
		{
			time += dy;
			x = x + nx*dy;
			y = y + ny*dy;
			ny = -ny;
		}

	}
	for (ll i : ans)
		cout << (i == infll ? -1:i) << '\n';

}

void solveD()
{
	int k; cin >> k;
	multiset < char > a;
	string s;
	cin >> s;
	for (int i = 0; i < s.size();)
	{
		char q = 127;
		int pl = 0;
		for (int j = 0; j < k && i+j<s.size(); j++)
		{
			if (q>=s[i + j])
			{
				q = s[i + j];
				pl = i + j;
			}
		}
		if (i + k >= s.size())
		{
			auto qw = a.end(); qw--;
			if (*qw > q)
				a.insert(q);
		}
			else
		a.insert(q);
		i = pl+1;

	}
	for (auto i : a)
		cout << i;

}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("input.txt", "w", stdout);
#endif
	solveD();
	/*int n = 100000;
	cout << 26 << endl;
	for (int j = 0; j < n; j++)
	{
		cout << (char)('a'+(j)%26);
	}*/
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
//libs
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <string>
#include <map>
#include <complex>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <queue>

using namespace std;
//defines
#define infll 1e18
#define ll long long
#define itn ll
#define vi vector<itn>
#define vvi vector<vi>
#define pii pair<itn,itn>
//constants
const double eps = 1e-7;
const ll mod = 1000000007;
//end of definition

void solve()
{
	ll n, m,k;
	cin >> n >> m >>k;

	set<pii> a;
	vector<pii> in(k);
	multimap<pii, ll> ma;
	for (ll i = 0; i < k; i++)
	{
		cin >> in[i].first >> in[i].second;
		if (in[i].first >= in[i].second)
		{
			ma.insert({ { in[i].first - in[i].second, 0 }, i });
			ma.insert({ { in[i].first + in[i].second, 0 }, i });
		}
		if (in[i].first >= m - in[i].second)
		{
			ma.insert({ { in[i].first - m + in[i].second, m }, i });
			ma.insert({ { in[i].first + m - in[i].second, m }, i });
		}
		if (in[i].second >= in[i].first)
		{
			ma.insert({ { 0, -in[i].first + in[i].second }, i });
			ma.insert({ { 0, in[i].first + in[i].second }, i });
		}
		if (n - in[i].first <= in[i].second)
		{
			ma.insert({ { n, in[i].first + in[i].second - n }, i });
			ma.insert({ { n, -in[i].first + in[i].second + n }, i });
		}
	}
	ll x=0, y=0;
	ll nx = 1, ny = 1;
	vector<ll> ans(k, infll);
	ll time = 0;
	multimap<pii, ll> rat;
	while (1)
	{
		while (ma.find({ x, y }) != ma.end())
		{
			ll ind = ma.find({ x, y })->second;
			if (ans[ind] != infll)
			{
				ma.erase(ma.find({ x, y }));
				continue;
			}
			pii na = in[ind];
			na.first -= x;
			na.second -= y;
			if (na.first / nx < 0)
			{
				rat.insert({ { x, y }, ind });
			}
			else
			ans[ind] = min(ans[ind], (na.first / nx) + time);
			ma.erase(ma.find({ x, y }));
		}
		while (rat.size())
		{
			ma.insert({ rat.begin()->first, rat.begin()->second });
			rat.erase(rat.begin());
		}

		if (a.find({ x, y }) != a.end())
			break;

		a.insert({ x, y });
		ll nextx = (nx == 1 ? n : 0);
		ll nexty = (ny == 1 ? m : 0);
		ll dx = abs((nextx-x) / nx);
		ll dy = abs((nexty-y) / ny);
		if (dx < dy)
		{
			time += dx;
			x = x + nx*dx;
			y = y + ny*dx;
			nx = -nx;
		}
		if (dx == dy)
			break;
		if (dx > dy)
		{
			time += dy;
			x = x + nx*dy;
			y = y + ny*dy;
			ny = -ny;
		}

	}
	for (ll i : ans)
		cout << (i == infll ? -1:i) << '\n';

}

void solveD()
{
	int k; cin >> k;
	multiset < char > a;
	string s;
	cin >> s;
	for (int i = 0; i < s.size();)
	{
		unsigned char q = 255;
		int pl = 0;
		for (int j = 0; j < k && i+j<s.size(); j++)
		{
			if (q>=s[i + j])
			{
				q = s[i + j];
				pl = i + j;
			}
		}
		if (i + k > s.size())
		{
			auto qw = a.end(); qw--;
			char q1 = *qw;
			if (q1 > q)
				a.insert(q);
			else
				break;
		}
		else
		a.insert(q);
		i = pl+1;

	}
	for (auto i : a)
		cout << i;
	cout << endl;

}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("input.txt", "w", stdout);
#endif
	solveD();
	/*int n = 100000;
	cout << 26 << endl;
	for (int j = 0; j < n; j++)
	{
		cout << (char)('a'+(j)%26);
	}*/
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
//libs
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <string>
#include <map>
#include <complex>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <queue>

using namespace std;
//defines
#define infll 1e18
#define ll long long
#define itn ll
#define vi vector<itn>
#define vvi vector<vi>
#define pii pair<itn,itn>
//constants
const double eps = 1e-7;
const ll mod = 1000000007;
//end of definition

void solve()
{
	ll n, m,k;
	cin >> n >> m >>k;

	vvi a(4, vi(max(n, m), 0));
	//a[0][0] = 1;
	vector<pii> in(k);
	multimap<pii, ll> ma;
	for (ll i = 0; i < k; i++)
	{
		cin >> in[i].first >> in[i].second;
		if (in[i].first >= in[i].second)
		{
			ma.insert({ { in[i].first - in[i].second, 0 }, i });
			ma.insert({ { in[i].first + in[i].second, 0 }, i });
		}
		if (in[i].first >= m - in[i].second)
		{
			ma.insert({ { in[i].first - m + in[i].second, m }, i });
			ma.insert({ { in[i].first + m - in[i].second, m }, i });

		}
		if (in[i].second >= in[i].first)
		{
			ma.insert({ { 0, -in[i].first + in[i].second }, i });
			ma.insert({ { 0, in[i].first + in[i].second }, i });
		}
		if (n - in[i].first <= in[i].second)
		{
			ma.insert({ { n, in[i].first + in[i].second - n }, i });
			ma.insert({ { n, -in[i].first + in[i].second + n }, i });

		}
	}
	ll x=0, y=0;
	ll nx = 1, ny = 1;
	vector<ll> ans(k, infll);
	ll time = 0;
	multimap<pii, ll> rat;
	while (1)
	{
		while (ma.find({ x, y }) != ma.end())
		{
			ll ind = ma.find({ x, y })->second;
			pii na = in[ind];
			na.first -= x;
			na.second -= y;
			if (na.first / nx < 0)
			{
				rat.insert({ { x, y }, ind });
			}
			else
			ans[ind] = min(ans[ind], (ll)na.first / nx +time);
			ma.erase(ma.find({ x, y }));
		}
		while (rat.size())
		{
			ma.insert({ rat.begin()->first, rat.begin()->second });
			rat.erase(rat.begin());
		}
		ll teku = 0, teku1;
		if (x == 0)
		{
			teku = 3;
			teku1 = y;
		}
		if (x == n)
		{
			teku = 1;
			teku1 = y;
		}
		if (y == 0)
		{
			teku = 0;
			teku1 = x;
		}
		if (y == m)
		{
			teku = 2;
			teku1 = x;
		}
		if (a[teku][teku1] == 1)
			break;
		a[teku][teku1] = 1;
		ll nextx = (nx == 1 ? n : 0);
		ll nexty = (ny == 1 ? m : 0);
		ll dx = abs((nextx-x) / nx);
		ll dy = abs((nexty-y) / ny);
		if (dx < dy)
		{
			time += dx;
			x = x + nx*dx;
			y = y + ny*dx;
			nx = -nx;
		}
		if (dx == dy)
			break;
		if (dx > dy)
		{
			time += dy;
			x = x + nx*dy;
			y = y + ny*dy;
			ny = -ny;
		}

	}
	for (ll i : ans)
		cout << (i == infll ? -1:i) << '\n';

}

void solveD()
{
	int k; cin >> k;
	multiset < char > a;
	string s;
	cin >> s;
	for (int i = 0; i < s.size();)
	{
		char q = 127;
		int pl = 0;
		for (int j = 0; j < k && i+j<s.size(); j++)
		{
			if (q>=s[i + j])
			{
				q = s[i + j];
				pl = i + j;
			}
		}
		if (i + k > s.size())
		{
			auto qw = a.end(); qw--;
			if (*qw > q)
				a.insert(q);
		}
			else
		a.insert(q);
		i = pl+1;

	}
	for (auto i : a)
		cout << i;

}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("input.txt", "w", stdout);
#endif
	solveD();
	/*int n = 100000;
	cout << 26 << endl;
	for (int j = 0; j < n; j++)
	{
		cout << (char)('a'+(j)%26);
	}*/
	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) int((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."
#define pi pair < int, int >

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = (int)1e5 + 123;

using namespace std;

int m;
string s;

vector < int > id[30];
set < int > q;

bool check(set < int > &q) {
	int last = -1;
	for (auto i : q) {
		if (i - last > m)
			return 0;
		last = i;
	}
	if (sz(s) - last > m)
		return 0;
	return 1;
}

void out(set < int > &q) {
	vector < char > ans;
	for (auto i : q)
		ans.pb(s[i]);
	sort(ans.begin(), ans.end());
	for (auto i : ans)
		cout << i;
	exit(0);
}

int main() {
	#ifdef Nick
	freopen(fname"in","r",stdin);
	freopen(fname"out","w",stdout);
	#endif
	ios_base :: sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
	cin >> m >> s;
	for (int i = 0; i < sz(s); i++)
		id[s[i] - 'a'].pb(i);
	for (int i = 0; i < 26; i++) {
		for (auto j : id[i])
			q.insert(j);
		if (check(q)) {
			for (auto j : id[i])
				q.erase(j);
			int now = 0, j = 0;
			while(now + m - 1 < sz(s)) {
			    auto it = q.lower_bound(now + m);
			    if (it != q.begin()) {
			    	it--;
			    	if (*it >= now) {
			    		now = *it + 1;
			    		continue;
			    	}
			    }
				while(j + 1 < sz(id[i]) && id[i][j + 1] < now + m)
					j++;
				assert(id[i][j] >= now);
				q.insert(id[i][j]);
				now = id[i][j++] + 1;
			}
			out(q);
		}
	}
	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) int((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."
#define pi pair < int, int >

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = (int)1e5 + 123;

using namespace std;

int m;
string s;

vector < int > id[30];
set < int > q;

bool check(set < int > &q) {
	int last = -1;
	for (auto i : q) {
		if (i - last > m)
			return 0;
		last = i;
	}
	if (sz(q) - last > m)
		return 0;
	return 1;
}

void out(set < int > &q) {
	vector < char > ans;
	for (auto i : q)
		ans.pb(s[i]);
	sort(ans.begin(), ans.end());
	for (auto i : ans)
		cout << i;
	exit(0);
}

int main() {
	#ifdef Nick
	freopen(fname"in","r",stdin);
	freopen(fname"out","w",stdout);
	#endif
	ios_base :: sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
	cin >> m >> s;
	for (int i = 0; i < sz(s); i++)
		id[s[i] - 'a'].pb(i);
	for (int i = 0; i < 26; i++) {
		for (auto j : id[i])
			q.insert(j);
		if (check(q)) {
			for (auto j : id[i])
				q.erase(j);
			int now = 0, j = 0;
			while(now + m - 1 < sz(s)) {
			    auto it = q.lower_bound(now + m);
			    if (it != q.begin()) {
			    	it--;
			    	if (*it >= now) {
			    		now = *it + 1;
			    		continue;
			    	}
			    }
				while(j + 1 < sz(id[i]) && id[i][j + 1] < now + m)
					j++;
				assert(id[i][j] >= now);
				q.insert(id[i][j]);
				now = id[i][j++] + 1;
			}
			out(q);
		}
	}
	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) int((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."
#define pi pair < int, int >

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = (int)1e5 + 123;

using namespace std;

int m;
string s;

vector < int > id[30];
set < int > q;

bool check(set < int > &q) {
	int last = -1;
	for (auto i : q) {
		if (i - last > m)
			return 0;
		last = i;
	}
}

void out(set < int > &q) {
	vector < char > ans;
	for (auto i : q)
		ans.pb(s[i]);
	sort(ans.begin(), ans.end());
	for (auto i : ans)
		cout << i;
	exit(0);
}

int main() {
	#ifdef Nick
	freopen(fname"in","r",stdin);
	freopen(fname"out","w",stdout);
	#endif
	ios_base :: sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
	cin >> m >> s;
	for (int i = 0; i < sz(s); i++)
		id[s[i] - 'a'].pb(i);
	for (int i = 0; i < 26; i++) {
		for (auto j : id[i])
			q.insert(j);
		if (check(q)) {
			for (auto j : id[i])
				q.erase(j);
			int now = 0, j = 0;
			while(now + m - 1 < sz(s)) {
			    auto it = q.lower_bound(now + m);
			    if (it != q.begin()) {
			    	it--;
			    	if (*it >= now) {
			    		now = *it + 1;
			    		continue;
			    	}
			    }
				while(j + 1 < sz(id[i]) && id[i][j + 1] < now + m)
					j++;
				assert(id[i][j] >= now);
				q.insert(id[i][j]);
				now = id[i][j++] + 1;
			}
			out(q);
		}
	}
	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) int((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."
#define pi pair < int, int >

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = (int)1e5 + 123;

using namespace std;

int m;
string s;

vector < int > id[30];
set < int > q;

bool check(set < int > &q) {
	int last = -1;
	for (auto i : q) {
		if (i - last > m)
			return 0;
		last = i;
	}
}

void out(set < int > &q) {
	vector < char > ans;
	for (auto i : q)
		ans.pb(s[i]);
	sort(ans.begin(), ans.end());
	for (auto i : ans)
		cout << i;
	exit(0);
}

int main() {
	#ifdef Nick
	freopen(fname"in","r",stdin);
	freopen(fname"out","w",stdout);
	#endif
	ios_base :: sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
	cin >> m >> s;
	for (int i = 0; i < sz(s); i++)
		id[s[i] - 'a'].pb(i);
	for (int i = 0; i < 26; i++) {
		for (auto j : id[i])
			q.insert(j);
		if (check(q)) {
			cout << i << endl;
			for (auto j : id[i])
				q.erase(j);
			int now = 0, j = 0;
			while(now + m - 1 < sz(s)) {
			    auto it = q.lower_bound(now + m);
			    if (it != q.begin()) {
			    	it--;
			    	if (*it >= now) {
			    		now = *it + 1;
			    		continue;
			    	}
			    }
				while(j + 1 < sz(id[i]) && id[i][j + 1] < now + m)
					j++;
				assert(id[i][j] >= now);
				q.insert(id[i][j]);
				now = id[i][j++] + 1;
			}
			out(q);
		}
	}
	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) int((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."
#define pi pair < int, int >

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = (int)1e5 + 123;

using namespace std;

int m;
string s;

vector < int > id[30];
set < int > q;

bool check(set < int > &q) {
	int last = -1;
	for (auto i : q) {
		if (i - last > m)
			return 0;
		last = i;
	}
	return 1;
}

void out(set < int > &q) {
	vector < char > ans;
	for (auto i : q)
		ans.pb(s[i]);
	sort(ans.begin(), ans.end());
	for (auto i : ans)
		cout << i;
	exit(0);
}

int main() {
	#ifdef Nick
	freopen(fname"in","r",stdin);
	freopen(fname"out","w",stdout);
	#endif
	ios_base :: sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
	cin >> m >> s;
	for (int i = 0; i < sz(s); i++)
		id[s[i] - 'a'].pb(i);
	for (int i = 0; i < 26; i++) {
		for (auto j : id[i])
			q.insert(j);
		if (check(q)) {
			for (auto j : id[i])
				q.erase(j);
			int now = 0, j = 0;
			while(now + m - 1 < sz(s)) {
			    auto it = q.lower_bound(now + m);
			    if (it != q.begin()) {
			    	it--;
			    	if (*it >= now) {
			    		now = *it + 1;
			    		continue;
			    	}
			    }
				while(j + 1 < sz(id[i]) && id[i][j + 1] < now + m)
					j++;
				assert(id[i][j] >= now);
				q.insert(id[i][j]);
				now = id[i][j++] + 1;
			}
			out(q);
		}
	}
	return 0;
}


#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<limits.h>
#include<stack>
#define pp pair<long long int,long long int>
using namespace std;
int main()
{
    long long int n;
    char a2[400];
    long long int array1[400];
    long long int array2[400][400];
    long long int pos[400];
    vector<long long int>v[400];
    cin>>n;
    for(long long int i=1;i<=n;i++)
    {
        cin>>array1[i];
        pos[array1[i]]=i;
    }
    for(long long int i=1;i<=n;i++)
    {
        cin>>a2;
        for(long long int j=1;j<=n;j++)
        {
            array2[i][j] = a2[j-1] - '0';
        }
    }

    for(long long int i=1;i<=n;i++)
    {
        for(long long int j=1;j<=n;j++)
        {
            if(array2[i][j]==1)
            {
                v[i].push_back(j);
                v[j].push_back(i);
            }
        }
    }
    long long int count1=1;
    while(1)
    {
        if(count1==0)
        break;
        else
        count1=0;

        for(long long int k=1;k<=n;k++)
        {
            long long int e = array1[k];

            long long int pos1 = pos[e];
            long long int size = v[pos1].size();
            for(long long int j=0;j<size;j++)
            {
                long long int pos2 = v[pos1][j];
                long long int e2 = array1[pos2];
                if(e2 > e && pos2 < pos1)
                {
                    long long int temp = array1[pos1];
                    array1[pos1] = array1[pos2];
                    pos[array1[pos2]] = pos1;
                    pos[temp] = pos2;
                    array1[pos2] = temp;
                    count1++;
                }
                else if(e2 < e && pos2 > pos1)
                {
                    long long int temp = array1[pos1];
                    array1[pos1] = array1[pos2];
                    pos[array1[pos2]] = pos1;
                    pos[temp] = pos2;
                    array1[pos2] = temp;
                    count1++;
                }

            }
        }

    }

    for(long long int i=1;i<=n;i++)
    {
        cout<<array1[i]<<" ";
    }

}


#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<limits.h>
#include<stack>
#define pp pair<long long int,long long int>
using namespace std;
int main()
{
    long long int n;
    char a2[400];
    long long int array1[400];
    long long int array2[400][400];
    long long int pos[400];
    vector<long long int>v[400];
    cin>>n;
    for(long long int i=1;i<=n;i++)
    {
        cin>>array1[i];
        pos[array1[i]]=i;
    }
    for(long long int i=1;i<=n;i++)
    {
        cin>>a2;
        for(long long int j=1;j<=n;j++)
        {
            array2[i][j] = a2[j-1] - '0';
        }
    }

    for(long long int i=1;i<=n;i++)
    {
        for(long long int j=1;j<=n;j++)
        {
            if(array2[i][j]==1)
            {
                v[i].push_back(j);
                v[j].push_back(i);
            }
        }
    }
    long long int count1=1;
    while(1)
    {
        if(count1==0)
        break;
        else
        count1=0;

        for(long long int k=1;k<=n;k++)
        {
            long long int e = array1[k];

            long long int pos1 = pos[e];
            long long int size = v[pos1].size();
            for(long long int j=0;j<size;j++)
            {
                long long int pos2 = v[pos1][j];
                long long int e2 = array1[pos2];
                if(e2 < e && pos2 > pos1)
                {
                    long long int temp = array1[pos1];
                    array1[pos1] = array1[pos2];
                    pos[array1[pos2]] = pos1;
                    pos[temp] = pos2;
                    array1[pos2] = temp;
                    count1++;
                }

            }
        }

    }

    for(long long int i=1;i<=n;i++)
    {
        cout<<array1[i]<<" ";
    }

}


#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<limits.h>
#include<stack>
#define pp pair<long long int,long long int>
using namespace std;
long long int n;
char a2[400];
long long int array1[400];
long long int array2[400][400];
long long int pos[400];
long long int visited[400];
vector<long long int>v[400];
long long int count1=0;
void dfs(long long int e)
{
    visited[e]=1;

    long long int size = v[e].size();

    for(long long int k=0;k<size;k++)
    {
        long long int p = v[e][k];
        if(visited[p]==0)
        {
            if(array1[p] < array1[e] && p > e)
            {
                long long int temp = array1[p];
                array1[p] = array1[e];
                array1[e] = temp;
                count1++;
            }

            if(array1[p] > array1[e] && p < e)
            {
                long long int temp = array1[p];
                array1[p] = array1[e];
                array1[e] = temp;
                count1++;
            }

            dfs(p);

            if(array1[p] < array1[e])
            {
                long long int temp = array1[p];
                array1[p] = array1[e];
                array1[e] = temp;
                count1++;
            }

            if(array1[p] > array1[e] && p < e)
            {
                long long int temp = array1[p];
                array1[p] = array1[e];
                array1[e] = temp;
                count1++;
            }
        }
    }

}
int main()
{
    cin>>n;
    memset(visited,0,sizeof(visited));
    for(long long int i=1;i<=n;i++)
    {
        cin>>array1[i];
        pos[array1[i]]=i;
    }
    for(long long int i=1;i<=n;i++)
    {
        cin>>a2;
        for(long long int j=1;j<=n;j++)
        {
            array2[i][j] = a2[j-1] - '0';
        }
    }
    for(long long int i=1;i<=n;i++)
    {
        for(long long int k=1;k<=n;k++)
        {
            for(long long int h=1;h<=n;h++)
            {
                if(array2[i][k]==1 && array2[k][h]==1)
                {
                    array2[i][h]=1;
                }
            }
        }
    }
    for(long long int i=1;i<=n;i++)
    {
        for(long long int j=1;j<=n;j++)
        {
            if(array2[i][j]==1)
            {
                v[i].push_back(j);
                v[j].push_back(i);
            }
        }
    }

    count1=1;
    while(1)
    {
    if(count1==0)
    break;
    else
    count1=0;
    for(long long int j=1;j<=n;j++)
    {
            //memset(visited,0,sizeof(visited));
            dfs(j);
    }
    }
    for(long long int j=1;j<=n;j++)
    {
        cout<<array1[j]<<" ";
    }
}


#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<limits.h>
#include<stack>
#define pp pair<long long int,long long int>
using namespace std;
long long int n;
char a2[400];
long long int array1[400];
long long int array2[400][400];
long long int pos[400];
long long int visited[400];
vector<long long int>v[400];
long long int count1=0;
void dfs(long long int e)
{
    visited[e]=1;

    long long int size = v[e].size();

    for(long long int k=0;k<size;k++)
    {
        long long int p = v[e][k];
        if(visited[p]==0)
        {
            if(array1[p] < array1[e] && p > e)
            {
                long long int temp = array1[p];
                array1[p] = array1[e];
                array1[e] = temp;
                count1++;
            }

            if(array1[p] > array1[e] && p < e)
            {
                long long int temp = array1[p];
                array1[p] = array1[e];
                array1[e] = temp;
                count1++;
            }

            dfs(p);

            if(array1[p] < array1[e])
            {
                long long int temp = array1[p];
                array1[p] = array1[e];
                array1[e] = temp;
                count1++;
            }

            if(array1[p] > array1[e] && p < e)
            {
                long long int temp = array1[p];
                array1[p] = array1[e];
                array1[e] = temp;
                count1++;
            }
        }
    }

}
int main()
{
    cin>>n;
    memset(visited,0,sizeof(visited));
    for(long long int i=1;i<=n;i++)
    {
        cin>>array1[i];
        pos[array1[i]]=i;
    }
    for(long long int i=1;i<=n;i++)
    {
        cin>>a2;
        for(long long int j=1;j<=n;j++)
        {
            array2[i][j] = a2[j-1] - '0';
        }
    }
    for(long long int i=1;i<=n;i++)
    {
        for(long long int k=1;k<=n;k++)
        {
            for(long long int h=1;h<=n;h++)
            {
                if(array2[i][k]==1 && array2[k][h]==1)
                {
                    array2[i][h]=1;
                }
            }
        }
    }
    for(long long int i=1;i<=n;i++)
    {
        for(long long int j=1;j<=n;j++)
        {
            if(array2[i][j]==1)
            {
                v[i].push_back(j);
                v[j].push_back(i);
            }
        }
    }

    count1=1;

    for(long long int j=1;j<=n;j++)
    {
            memset(visited,0,sizeof(visited));
            dfs(j);
    }
    for(long long int j=1;j<=n;j++)
    {
        cout<<array1[j]<<" ";
    }
}


#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<limits.h>
#include<stack>
#define pp pair<long long int,long long int>
using namespace std;
long long int n;
char a2[400];
long long int array1[400];
long long int array2[400][400];
long long int pos[400];
long long int visited[400];
vector<long long int>v[400];
long long int count1=0;
void dfs(long long int e)
{
    visited[e]=1;

    long long int size = v[e].size();

    for(long long int k=0;k<size;k++)
    {
        long long int p = v[e][k];
        if(visited[p]==0)
        {
            if(array1[p] < array1[e])
            {
                long long int temp = array1[p];
                array1[p] = array1[e];
                array1[e] = temp;
                count1++;
            }

            dfs(p);

            if(array1[p] < array1[e])
            {
                long long int temp = array1[p];
                array1[p] = array1[e];
                array1[e] = temp;
                count1++;
            }
        }
    }

}
int main()
{
    cin>>n;
    memset(visited,0,sizeof(visited));
    for(long long int i=1;i<=n;i++)
    {
        cin>>array1[i];
        pos[array1[i]]=i;
    }
    for(long long int i=1;i<=n;i++)
    {
        cin>>a2;
        for(long long int j=1;j<=n;j++)
        {
            array2[i][j] = a2[j-1] - '0';
        }
    }
    for(long long int i=1;i<=n;i++)
    {
        for(long long int j=1;j<=n;j++)
        {
            if(array2[i][j]==1)
            {
                if(i<j)
                v[i].push_back(j);
                if(j<i)
                v[j].push_back(i);
            }
        }
    }
    for(long long int i=1;i<=n;i++)
    {
        for(long long int k=1;k<=n;k++)
        {
            for(long long int h=1;h<=n;h++)
            {
                if(array2[i][k]==1 && array2[k][h]==1)
                {
                    if(i<h)
                    {
                        v[i].push_back(h);
                    }
                    else if(h<i)
                    {
                        v[h].push_back(i);
                    }
                }
            }
        }
    }
    count1=1;
    while(1)
    {
    if(count1==0)
    break;
    else count1=0;
    for(long long int j=1;j<=n;j++)
    {
            memset(visited,0,sizeof(visited));
            dfs(j);
    }
    }
    for(long long int j=1;j<=n;j++)
    {
        cout<<array1[j]<<" ";
    }
}