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