#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  while (cin >> s) {
    if (s[0] < '9' && s[0] >= '5') s[0] = 9 - s[0] + '0' + '0';
    for (int i = 1; i < s.length(); i++)
      if (s[i] <= '9' && s[i] >= '5') s[i] = 9 - s[i] + '0' + '0';
    cout << s << endl;
  }
  return 0;
}
