object Main {
    def step(s: (Char, Char, Char), c: String) = c match {
        case "AB" => (s._2, s._1, s._3)
        case "BC" => (s._1, s._3, s._2)
        case "AC" => (s._3, s._2, s._1)
    }
    def main(args: Array[String]) = {
        val in = io.Source.stdin.getLines.map(_.sorted.tail)
        println(in.foldLeft(('A', 'B', 'C'))(step)._1)
    }
}