a = str(int(str(input())[::-1]))

result = ""

for char in a:
    if char == '2':
        result += '5'
    elif char == '5':
        result += '2'
    else:
        result += char
        
print(result)