#include <bits/stdc++.h>
int main() {
  std::string number;
  std::getline(std::cin, number);
  for (int i = 0; i < number.size(); ++i) {
    if (i == 0 && number[i] - '0' - 9 == 0) {
      continue;
    }
    auto num = number[i] - '0';
    if (num > 9 - num) {
      number[i] = 9 - num + '0';
    }
  }
  std::cout << number << std::endl;
  return 0;
}
