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

int main()
{
    string str;
    cin >> str;

    int i = 0;
    int txtsize = str.size();
    string after = "";

    for (int j = txtsize; j >= 0; j--)
    {
        string ch = str.substr(j, 1);

        if (ch == "6")
        {
            ch = "9";
        }
        else if (ch == "9")
        {
            ch = "6";
        }

        after += ch;

        i++;
    }

    std::cout << after << std::endl;
}

#include <bits/stdc++.h>

using namespace std;

int main() {
    string s;
    cin >> s;

    reverse(s.begin(), s.end());

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '6') {
            cout << '9';
        }
        else if (s[i] == '9') {
            cout << '6';
        }
        else {
            cout << s[i];
        }
    }

    cout << endl;
    
}