#include <bits/stdc++.h>
using namespace std;
long long x;
int a[1005];
int main() {
  cin >> x;
  int i = 0;
  while (x > 0) {
    if (x % 10 > (9 - x % 10)) {
      a[i] = (9 - x % 10);
    } else {
      a[i] = x % 10;
    }
    ++i;
    x /= 10;
  }
  for (int j = i - 1; j >= 0; --j) {
    if (a[i - 1] == 0) {
      a[i - 1] = 9;
    }
    cout << a[j];
  }
}
