#include <iostream>
using namespace std;

int main() {
    long long n;
    long long m = 0; 
    cin >> n;
    
    while (n) {
        if (n % 10 == 5) {
            m = m * 10 + 2;
        }
        else if (n % 10 == 2) {
            m = m * 10 + 5; 
        }
        else {
            m = m * 10 + (n % 10);
        }
        n /= 10; 
    }  

    cout << m;
    return 0; 
}