object Main {
    def step(l: List[Int], c: Array[Int]) = l.updated(c(0), l(c(1))).updated(c(1), l(c(0)))
    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines.map(_.split(",").map(_(0) - 65))
        println((in.foldLeft(List(1, 0, 0))(step).indexWhere(_ == 1) + 65).toChar)
    }
}