#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ios_base::sync_with_stdio(false);
	ll a, res = 0;
	cin>>a;
	while(a > 0){
	    res *= 10;
	    ll k = a%10;
	    if(k == 2) k = 5;
	    else if(k == 5) k = 2;
	    res+=k;
	    a/=10;
	}cout<<res;
}