a=str(input())
b=int(str(a[::-1]))
b = str(b)
if int(a)==int(b[::-1]):
    print(int(a[::-1]))
else:
    b = str(b)
    b = b.replace('2','a')
    b = b.replace('5','2')
    b = b.replace('a','5')
    print(b)
