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