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