def mirror_number(k):
    k_str = str(k)
    reversed_str = k_str[::-1]  
    mirrored = ""
    for digit in reversed_str:
        if digit == "2":
            mirrored += "5"
        elif digit == "5":
            mirrored += "2"
        else:
            mirrored += digit
    return int(mirrored)

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