n = gets.to_i order = +"" while n > 1 if n.odd? order.prepend("A") n = (n - 1) / 2 else order.prepend("B") n = (n - 1) / 3 end end puts order