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

