#include <iostream> 
#include <sstream> 
#include <string> 
#include <algorithm> 
#include <cstdlib> 
 
using namespace std; 
 
int main() { 
    long long k; 
    cin >> k; 
 
    if (k < 1 || k > 1000000000000000000LL) { 
        cout << "Invalid input. Please enter a number between 1 and 10^18." << endl; 
        return 1;  
    } 
 
    ostringstream convert; 
    convert << k; 
    string num = convert.str(); 
    string reflectedNum = ""; 
 
    for (int i = num.length() - 1; i >= 0; --i) { 
        char digit = num[i]; 
        if (digit == '5') { 
            reflectedNum += '2'; 
        } else if (digit == '2') { 
            reflectedNum += '5'; 
        } else { 
            reflectedNum += digit; 
        } 
 } 
    reflectedNum.erase(0, min(reflectedNum.find_first_not_of('0'), reflectedNum.size() - 1)); 
 
    cout << reflectedNum << endl; 
 
    return 0; 
}
