#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin>>s;
while (s[s.size()-1]=='0')
  {  s.erase(s.size()-1);}
for (int i=s.size()-1;i>=0;i--)
    { 
        if (s[i]=='5') s[i]='2';
        else if (s[i]=='2') s[i]='5';
        cout<<s[i];
    }
}