#include <bits/stdc++.h>
using namespace std;
int main() {
  char ch;
  int i;
  long long a = 0;
  ch = getc(stdin);
  if (ch == '9')
    a = a * 10 + 9;
  else
    a = a * 10 + min(ch - '0', 9 - (ch - '0'));
  ch = getc(stdin);
  while (ch != '\n') {
    a = a * 10 + min(ch - '0', 9 - (ch - '0'));
    ch = getc(stdin);
  }
  printf("%I64d\n", a);
  return 0;
}
