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