k=int(input())
z=list(map(lambda x: int(x), str(k)))
c=list(reversed(z))
ln=len(c)
for i in range(ln):
    if c[i]==5:
        c[i]=2
        continue
    if c[i]==2:
        c[i]=5
        continue
if c[0]==0:
    c.remove(0)
print(int(''.join(map(str,c))))


    
