#ifndef LOCAL
#pragma GCC optimize ("O3")
#endif

#include <bits/stdc++.h>

using namespace std;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (c it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(x...) " [" #x ": " << (x) << "] "

using ld = long double;
using ll = long long;

constexpr int mod = 1000 * 1000 * 1000 + 7;
constexpr int odw2 = (mod + 1) / 2;

void OdejmijOd(int& a, int b) { a -= b; if (a < 0) a += mod; }
int Odejmij(int a, int b) { OdejmijOd(a, b); return a; }
void DodajDo(int& a, int b) { a += b; if (a >= mod) a -= mod; }
int Dodaj(int a, int b) { DodajDo(a, b); return a; }
int Mnoz(int a, int b) { return (ll) a * b % mod; }
void MnozDo(int& a, int b) { a = Mnoz(a, b); }
int Pot(int a, int b) { int res = 1; while (b) { if (b % 2 == 1) MnozDo(res, a); a = Mnoz(a, a); b /= 2; } return res; }
int Odw(int a) { return Pot(a, mod - 2); }
void PodzielDo(int& a, int b) { MnozDo(a, Odw(b)); }
int Podziel(int a, int b) { return Mnoz(a, Odw(b)); }
int Moduluj(ll x) { x %= mod; if (x < 0) x += mod; return x; }

template <typename T> T Maxi(T& a, T b) { return a = max(a, b); }
template <typename T> T Mini(T& a, T b) { return a = min(a, b); }

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  vector<string> parts;
  int bal = 0;
  string last_part;
  for (char c : s) {
    if (c == 'a') bal++;
    else if (c == 'b') bal--;
    else assert(false);
    last_part.push_back(c);
    if (bal == 0) {
      parts.push_back(last_part);
      last_part.clear();
    }
  }
  assert(last_part.empty());
  debug() << imie(parts);

  for (string& p : parts) {
    assert((int) p.size() % 2 == 0);
    string res;
    if (p[0] == 'a') {
      vector<pair<int, int>> v;
      for (int i = 0; i < (int) p.size(); i++) {
        if (p[i] == 'a') {
          p[i] = 'o';
          for (int j = i + 1; j < (int) p.size(); j++) {
            if (p[j] == 'b') {
              p[j] = 'o';
              v.emplace_back(i, j);
              break;
            }
          }
        }
      }
      int cnt = 0;
      int last_b = -1;
      for (auto& q : v) {
        if (last_b < q.first) {
          cnt++;
          last_b = q.second;
        }
      }
      while (cnt--) {
        res += "ab";
      }
    } else {
      for (int i = 0; i < (int) p.size() / 2; i++) {
        string st;
        int zost[2] = {i, i};
        for (char c : p) {
          int idx = 0;
          if (c == 'b') idx = 1;
          if (zost[idx] > 0) {
            zost[idx]--;
          } else {
            st.push_back(c);
          }
        }
        Maxi(res, st);
      }
    }
    swap(res, p);
  }
  debug() << imie(parts);
  string wyn;
  for (int i = (int) parts.size() - 1; i >= 0; i--) {
    if (parts[i] + wyn > wyn) {
      wyn = parts[i] + wyn;
    }
  }
  cout << wyn << endl;
  return 0;
}


Measured memory_bytes: 512