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