class P174
  def main
    pa=0, pb=0
    while (line=gets.chomp)!='0'
      line[1..-1].each_char { |ch|
        case ch
          when 'A'
            pa+=1
          when 'B'
            pb+=1
        end
      }
      puts "#{pa} #{pb}"
    end
  end
end

P174.new.main