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