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