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