#include <iostream>

size_t Mirror(size_t n) {
    size_t res = 0;
    while (n != 0) {
        res *= 10;
        auto digit = n % 10;
        if (digit == 2) {
            digit = 5;
        } else if (digit == 5) {
            digit = 2;
        }
        res += digit;
        n /= 10;
    }
    return res;
}


int main() {
    size_t n;
    std::cin >> n;
    std::cout << Mirror(n);
}