diff --git a/buggy.py b/buggy.py
--- a/buggy.py
+++ b/buggy.py
@@ -1,5 +1,5 @@
 N = int(input())
 S = input()
 d = S.split("C")
-d = ["A" * p.count("A") + "B" * p.count("B") for p in d]
+d = ["A" * (p.count("A") + p.count("B") // 2) + "B" * (p.count("B") % 2) for p in d]
 print("C".join(d))
