#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  for (char &ch : s) {
    if (ch > '4') ch = '9' - ch + '0';
  }
  if (s[0] == '0') s[0] = '9';
  cout << s;
  return 0;
}
