public void solve() throws IOException {
    char[] input = nextLine().toCharArray();
    for (int x = 0; x < input.length; x++) {
      if (input[x] >= '5') {
        if (x != 0 || input[x] != '9') {
          input[x] = (char) ('9' - input[x] + '0');
        }
      }
    }
    System.out.println(new String(input));
  }