#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,rem,reverse;
    cin>>n;
    while (n > 0) {
    rem = n % 10;
    if(rem==5){
        rem=2;
    }
    else if(rem==2){
        rem=5;
    }
    reverse=reverse*10+rem;
    n/=10;
    }
    cout<<reverse;
} 
