#include <bits/stdc++.h>
using namespace std;
int main() {
  char b[20];
  gets(b);
  if (b[0] > '4' && b[0] != '9') b[0] = '9' - b[0] + '0';
  for (int i = 1; b[i] != '\0'; i++) {
    if (b[i] > '4') b[i] = '9' - b[i] + '0';
  }
  puts(b);
  return 0;
}
