def mirror_number(k):
    result = 0
    multiplier = 1

    while k > 0:
        digit = k % 10 
        if digit == 2:
            digit = 5
        elif digit == 5:
            digit = 2
        result = result * 10 + digit
        k = k // 10  

    return result

k = int(input())
print(mirror_number(k))
