#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int n, u[6009], depth[6009], num[6009]; string S; pair<string, int> dp[6009]; bool used[6009];
vector<int>A, B;

int main() {
	cin >> n >> S;
	for (int i = 0; i < 2 * n; i++) {
		if (S[i] == 'b') { depth[i + 1] = depth[i] + 1; num[i] = B.size(); B.push_back(i); }
		else { depth[i + 1] = depth[i] - 1; num[i] = A.size(); A.push_back(i); }
		if (depth[i + 1] == 0) used[i] = true;
	}
	for (int i = 2 * n - 1; i >= 0; i--) { if (used[i] == true) u[i] = i; else u[i] = u[i + 1]; }

	for (int i = 2 * n - 1; i >= 0; i--) {
		dp[i] = dp[i + 1];
		if (depth[i + 1] > 0 && S[i] == 'b') {
			string V = "";
			for (int j = i; j < A[num[i]]; j++) { if (S[j] == 'b') V += S[j]; }
			for (int j = A[num[i]]; j <= u[i]; j++) V += S[j];
			dp[i] = max(dp[i], make_pair(V, -i));
		}
	}
	string ans = ""; int cx = 0;
	while (dp[cx].first != "") {
		ans += dp[cx].first;
		cx = u[dp[cx].second * -1] + 1;
	}
	for (int i = 0; i < A.size(); i++) {
		if (A[i] >= cx) { cx = B[i] + 1; ans += "ab"; }
	}
	cout << ans << endl;
	return 0;
}