#include <bits/stdc++.h>
using namespace std;
int main(void) {
  char s[20];
  gets(s);
  if (s[0] >= '5' && s[0] != '9')
    cout << '9' - s[0];
  else
    cout << s[0];
  for (int i = 1; s[i] != '\0'; i++) {
    if (s[i] >= '5')
      cout << '9' - s[i];
    else
      cout << s[i];
  }
  cout << endl;
  return 0;
}
