#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int l = str.length();
  int i;
  for (i = 0; i < l; i++) {
    if (i == 0 && str[i] == '9') {
      cout << str[i];
      continue;
    }
    char c = str[i];
    int x = c - 48;
    if (x > 4) x = 9 - x;
    cout << (char)(48 + x);
  }
  return 0;
}
