import sys i = map(int, raw_input().split()) for a in i: if not i[a] == a + 1: print(a + 1) sys.exit()