import Data.List

solve :: Int -> String -> String
solve _ s = foldr1 f $ map solveB (mkBlocks s)
  where
    f s1 s2 | cmpless s1 s2 = s2
            | otherwise     = s1 ++ s2

cmpless (x : s) (y : t) | x == y = cmpless s t
                        | otherwise = x < y
cmpless _ _ = False

mkBlocks = unfoldr f
  where
    f "" = Nothing
    f s@(c:_) = let cnts = (takeWhile (> 0) (tail (scanl' g 0 s))) ++ [0]
                    (s1, s2) = splitAt (length cnts) s
                in Just $ ((s1, cnts), s2)
      where g n c' | c' == c   = n + 1
                   | otherwise = n - 1

solveB (s@('a':_), _) = take (2*count) $ cycle "ab"
  where
    count = sub 0 0 0 s

    sub ia ib cnt [] = cnt
    sub ia ib cnt ('a':s) = sub2 ia (ia+1) ib cnt s
    sub ia ib cnt ('b':s) = sub ia (ib+1) cnt s

    sub2 ga ia ib cnt ('a':s) = sub2 ga (ia+1) ib cnt s
    sub2 ga ia ib cnt ('b':s) | ga == ib = sub ia (ib+1) (cnt+1) s
                              | otherwise = sub2 ga ia (ib+1) cnt s

solveB (s@('b':_), cnts) =
  maximum [take cmax (repeat 'b') ++ drop i s
          | (i, cnt) <- zip [1..] cnts, cnt == cmax]
  where
    cmax = maximum cnts

main = do
  cont <- getContents
  let [sn, s] = words cont
  putStrLn $ solve (read sn) s
