# Ansh Moraje
# Bergen County Academies
# Intermediate Divison
# 3/2/20


def main():
    inputFile = open("3int_sampledata.txt", "r")

    output = {}


    for i in range(0, 4, 1):
        if i > 1:
            theB = 98

        else:
            theB = 66

        if i == 0 or i == 3:
            theD = 100

        else:
            theD = 68

        for j in range(0, 4, 1):

            if j > 1:
                theA = 97

            else:
                theA = 65

            if j == 0 or j == 3:
                theC = 99

            else:
                theC = 67

            output[chr(theA) + chr(theB) + chr(theC) + chr(theD)] = False


    for line in inputFile:

        input = line.strip().split("+")
        #for i in output:
         #   print(i + ": " + str(output[i]))

        for i in range(0, len(input), 1):
            for j in range(65, 69, 1):
                input[i] = input[i].replace("~" + chr(j), chr(j+32))



        for i in output:

            for j in input:
                count = 0
                for k in j:

                    if k not in i:
                        break
                    if count == len(j)-1:
                        output[i] = True

                    count += 1

        count = 3
        num = 0
        hexAnswer = ""

        for i in output:
            if output[i]:
                num += 2 ** count


            if(count == 0):
                count = 3
                hexAnswer += str(hex(num).split("x")[-1])
                num = 0
                continue

            count -= 1


        print(hexAnswer.upper())


        for i in output:
            output[i] = False


main()