loop do
    l = gets.chomp
    break if l == ?0
    h = {?A => 0, ?B => 0}
    l.split("").each_cons(2) do |c1, c2|
        h[c1 == c2 ? c1 : c2] += 1
    end
    h[?A] > h[?B] ? h[?A] += 1 : h[?B] += 1
    puts h.values * ' '
end

