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