#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int i, sz;
  string s;
  cin >> s;
  sz = s.size();
  for (i = 0; i < sz; i++) {
    if (i == 0 && s[i] == '9') continue;
    if (s[i] > '4') s[i] = '0' + '9' - s[i];
  }
  cout << s << "\n";
  return 0;
}
