#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin >> n;
	int flag = 0;
	long long k = 0;
	while (n > 0){
    	if (flag == 0 and n % 10 == 0){
    		n = n / 10;
    		continue;
		}
    	if (n % 10 != 0){
        	flag = 1;
    	}
        if (n % 10 == 5){
        	k = k * 10 + 2;
		}
        else if (n % 10 == 2){
        	k = k * 10 + 5;
		}
        else k = k * 10 + n % 10;
    	n = n / 10;
	}  
	cout<<k;
}
