#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (!i)
      if (s[i] == '9') continue;
    if (s[i] - '0' > 4) s[i] = char(9 - int(s[i] - '0') + '0');
  }
  cout << s << endl;
}
