#include <bits/stdc++.h>
using namespace std;
int main() {
  char c[20];
  cin >> c;
  for (int i = 0; i < 20; i++) {
    ;
    if (c[i] - 48 >= 5 && c[i] - 48 <= 9) c[i] = 105 - c[i];
  }
  if (c[0] == '0') c[0] = '9';
  cout << c << endl;
  return 0;
}
