#include <bits/stdc++.h>
using namespace std;
#define int long long

const int N = 3e5 + 100 ;

int a[N] ;

signed main() {

    string s ;
    cin >> s ;
    for ( int i = 0 ; i < s.size() ; i++ )
    {
        if ( s[i] == '2' )
            s[i] =  '5' ;
        else if ( s[i] == '5' )
            s[i] = '2' ;
    }
    reverse( s.begin() , s.end() ) ;
    int u = stoi(s) ;
    cout << u ;
}