num=input() X,Y,Z=[int(num[s]) for s in num.split(" ")] count=0 for i in range(0,Z,1): if count==X: count=count elif count==Y: count=count else: count+=1 print(count)