#include <iostream>
#include <string>

using namespace std;

int n;
string s;
int a[3005], b[3005];
int order[6005];

string calc(int l, int r, string &ans)
{
	string ret;
	if(s[l] == 'a'){
		if(ans.size() && ans[0] == 'b') return ans;
		int x = l;
		while(x <= r){
			ret += "ab";
			x = b[order[x]];
			while(x <= r && s[x] != 'a') x++;
		}
		ret += ans;
		return ret;
	}
	
	ret = ans;
	for(int i = l; i <= r; i++){
		if(s[i] == 'a') continue;
		int p = a[order[i]];
		string tmp;
		for(int j = i; j <= r; j++){
			if(s[j] == 'b') tmp += "b";
			else if(j >= p) tmp += "a";
		}
		ret = max(ret, tmp + ans);
	}
	return ret;
}

int main(void)
{
	cin >> n;
	cin >> s;
	s = "#" + s;
	n *= 2;
	
	int aid = 1, bid = 1;
	for(int i = 1; i <= n; i++){
		if(s[i] == 'a') a[aid] = i, order[i] = aid++;
		if(s[i] == 'b') b[bid] = i, order[i] = bid++;
	}
	
	string ans; int l = n+1, r = n;
	for(int i = n; i >= 1; i--){
		if(s[i] == 'a') l = min(l, b[order[i]]);
		if(s[i] == 'b') l = min(l, a[order[i]]);
		if(i == l){
			ans = calc(l, r, ans);
			r = l-1;
		}
	}
	cout << ans << endl;
	
	return 0;
}