#include <bits/stdc++.h>
#define first f
#define second s

using namespace std;

long long  a,b , i, j,n,m,k,q,f;
string s,s1;
int main()
{
cin >> s;
for (i=s.size()-1; i>=0; i--){
    if(s[i]=='0' and f==0) continue;
    else if (s[i]!='0' and f==0){
        f=1;
        if (s[i]=='2') cout << 5;
        else if (s[i]=='5') cout << 2;
        else cout << s[i];
    }
    else if (f==1){
      if (s[i]=='2') cout << 5;
        else if (s[i]=='5') cout << 2;
        else cout << s[i];
    }
}
cout << endl;

    return 0;
}
