num = int(input())
if num > 0:
    def reverse_and_replace(num):
        reversed_num = str(num)[::-1]
        result = ''
        for digit in reversed_num:
            if digit == '5':
                result += '2'
            elif digit == '2':
                result += '5'
            elif digit != '0':
                result += digit
        return int(result)
    print(reverse_and_replace(num))
else:
    print(num)
