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