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