#include <bits/stdc++.h>
using namespace std;
long long i = 1, n, k, b, k2, j;
int main() {
  cin >> n;
  while (n > 0) {
    k = n % 10;
    if (k > 4 && n != 9) k = 9 - k;
    b = b + k * i;
    i = i * 10;
    n = n / 10;
  }
  cout << b;
}
