#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s[0] != 57) {
    for (int i = 0; i < s.length(); i++) {
      if (57 - s[i] < s[i] - 48) s[i] = 57 - s[i] + 48;
    }
  } else {
    for (int i = 1; i < s.length(); i++) {
      if (57 - s[i] < s[i] - 48) s[i] = 57 - s[i] + 48;
    }
  }
  cout << s;
}
