#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  string s = "";
  cin >> s;
  int a;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] > '4') {
      if ((i == 0 && s[i] != '9') | i != 0) s[i] = (9 - (s[i] - '0')) + '0';
    }
  }
  cout << s;
  return EXIT_SUCCESS;
}
