#include <bits/stdc++.h>
using namespace std;
void invt(char &x) { x = '0' + 9 - x + '0'; }
int main() {
  char num[35];
  cin >> num;
  if (num[0] != '9' && num[0] >= '5') {
    invt(num[0]);
  }
  for (int i = 1; i < strlen(num); i++) {
    if (num[i] >= '5') invt(num[i]);
  }
  cout << num;
  return 0;
}
