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