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