#include <bits/stdc++.h>
int main(void) {
  int i = 0;
  char a[20];
  scanf("%s", a);
  while (a[i] != '\0') {
    if (i == 0) {
      if (a[i] != '9' && (a[i] - '5') >= 0) {
        a[i] = '9' - a[i] + '0';
      }
    } else {
      if ((a[i] - '5') >= 0) {
        a[i] = '9' - a[i] + '0';
      }
    }
    i++;
  }
  printf("%s", a);
  return 0;
}
