n=int(input())

sn=list(str(n))

isn=[(int(i)+3)%9 for i in sn]
isn[0],isn[2]=isn[2],isn[0]
isn[1],isn[3]=isn[3],isn[1]

s=''
sisn=[str(i) for i in isn]

for i in sisn:
    s+=i
print(s)