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