#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  for (long long i = 0; i < s.size(); i++) {
    if ((s[i] - '0') >= 5) {
      if (i == 0 && s[i] == '9')
        continue;
      else
        s[i] = (9 - (s[i] - '0')) + '0';
    }
  }
  cout << s << endl;
}
