#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ld long double
#define fir first
#define sec second
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
using namespace std;
void solve(){
string s;
cin >> s;
reverse(all(s));

for(ll i=0; i<sz(s); i++)
{
    if(s[i]=='2') s[i]='5';
    else if(s[i]=='5') s[i]='2';
}

ll s1=atoll(s.c_str());
cout << s1;
}

int main()
{
    solve();
    return 0;
}
