a = input()
b = []
for i in range(len(a)):
    x = (int(a[i])+3)%9
    b.append(x)
b[0], b[2] = b[2], b[0]
b[1], b[3] = b[3], b[1]
for i in b:
    print(i, end="")