#include <bits/stdc++.h>
using namespace std;
char a[20];
signed main() {
  scanf("%s", a);
  for (long long i = 0; a[i]; i++) a[i] = min(a[i], char(9 + '0' - a[i] + '0'));
  if (a[0] == '0') a[0] = '9';
  printf("%s", a);
  return 0;
}
