#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  for (auto &e : str) {
    int tmp = e - '0';
    if (9 - tmp < tmp) e = (9 - tmp) + '0';
  }
  if (str[0] == '0') str[0] = '9';
  cout << str << endl;
  return 0;
}
