k = input()
def reversed1(o):
    o1 = ''.join(reversed(o))
    return o1
h = reversed1(k)
h1 = list(h)
for i in range(0,len(h1)):
    if h1[i]=="5":
        h1[i]="2"
    elif h1[i]=="2":
        h1[i]="5"
    elif h1[i]=="0":
        if i==0 or i==len(h1)-1:
            h1[i]=""
print(''.join(h1))



# import numpy as np

# n = int(input())
# m = int(input())
# arr = [n,m]
# for i in range(n):
#     for j in range(m):
#         arr[i][j] = input()
# for i in range(n):
#     for j in range(m):
#         print(arr[i][j])


# n,m=map(int,input().split())
# arr = []
# for i in range(m):
#     arr[m] = int(input())
# arr1[0]

# while len(arr)!=0:
#     el = arr[0]
#     arr.pop(el)
#     counter = 1
#     for i in arr:
#         if arr[i]==el:
#             counter = counter +1
#     if counter >= n:
#         arr1.add(el)
# print(counter)
    