#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  int i = 0;
  if (a[0] == '9') i = 1;
  for (; i < a.size(); ++i) {
    if (a[i] > '4') a[i] = ('9' - a[i]) + '0';
  }
  cout << a;
}
