def mirror_number(k):
    mirrored = 0

    while k > 0:
        digit = k % 10

        if digit == 2:
            mirrored = mirrored * 10 + 5
        elif digit == 5:
            mirrored = mirrored * 10 + 2
        else:
            mirrored = mirrored * 10 + digit

        k = k // 10

    return mirrored

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