#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string str;
    cin >> str;
    for (int i = 0; i < str.length(); i++) {
        if (str[i] == '2') {
            str[i] = '5';
        }
        else {
            if (str[i] == '5') {
                str[i] = '2';
            }
        }
    }
    reverse(str.begin(), str.end());
    int i = 0;
    while (str[i] == '0')
        i++;
    str.erase(0, i);
    cout << str;
}