local tgt = 1
local strs = {}
local pos = {1, 1, 1}
local tmp = ""
for i = 1, 3 do strs[i] = io.read() end
while pos[tgt] <= #(strs[tgt]) do
  tmp = strs[tgt]:sub(pos[tgt], pos[tgt])
  pos[tgt] = pos[tgt] + 1
  tgt = string.byte(tmp) - 96
end
print(string.char(tgt + 64))
