#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    int a = (int)(s[i] - '0');
    int b = 9 - a;
    int c = min(a, b);
    if (c == 0 && i == 0)
      cout << a;
    else
      cout << c;
  }
  return 0;
}
