#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll n, a, m = 0;
    cin >> n;
	while (n){
		a = n % 10;
		if (a == 2){
			a = 5;
			m = m * 10 + a;
		}
		else if (a == 5){
			a = 2;
			m = m * 10 + a;		
		}
		else{
			m = m * 10 + a;	
		}
		n /= 10l
	}
	cout << m << endl;
}

