number = input()
list = []
for i in range(len(number)):
    b = (int(number[i])+3)%9
    list.append(b)
list[0],list[2] = list[2],list[0]
list[1],list[3] = list[3],list[1]
print("".join('%s'%id for id in list))