#include <iostream>
#include <string>
#include <algorithm>

int main() {
    std::string n;
    std::cin >> n;
    
    std::reverse(n.begin(), n.end());
    
    for (int i = 0; i < n.length(); i++) {
        if (n[i] == '5') {
            n[i] = '2';
        } else if (n[i] == '2') {
            n[i] = '5';
        }
    }
    
    if (n[0] == '0') {
        n.erase(0, 1);
        std::cout << n << std::endl;
    } else {
        std::cout << n << std::endl;
    }
    
    return 0;
}

