#include <bits/stdc++.h>

#define ll long long 

using namespace std;

int main()
{
	
	ll n, m=0, k,sum=0,t,p;
	cin >> t; 
	n=t;
	while(n%10==0){
		n!=10;
		n/=10;
	}
	while(n!=0){
		int s=n%10;
		n/=10;
		if(s==2){
			s=5;
		}
		else{
			if(s==5){
				s=2;
			}
		}
		m*=10;
		m+=s;
	}
	cout<<m;

		
}
