a=list(input())
s=''
if a[-1]=='0':
    a.pop(-1)
for i in range(len(a)):
    if a[i]=='2':
        a[i]=5
    elif a[i]=='5':
        a[i]=2
a=a[::-1]
for i in range(len(a)):
    s+=str(a[i])
print(s)
