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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    auto start = chrono::high_resolution_clock::now();

    unsigned long long int a,ans=0;
    cin>>a;
    while(a){
        ans*=10;
        int b=a%10;
        if(b==5){
            ans+=2;
        }else if(b==2){
            ans+=5;
        }else{
            ans+=b;
        }
        a/=10;
    }
    cout<<ans;

    #ifdef Bilol
    auto duration = chrono::duration_cast<chrono::microseconds>(chrono::high_resolution_clock::now() - start);
    cout << endl << "time: " << (double)duration.count() / 1000.0 << " milliseconds" << endl;
    #endif
}