#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long m = 0;
  long long i = 1;
  string s = to_string(n);
  long long np = s.length();
  int cnt = 1;
  while (n != 0) {
    int t = n % 10;
    if (9 - t < t) {
      if (cnt != np)
        m += (9 - t) * i;
      else if (t != 9)
        m += (9 - t) * i;
      else
        m += t * i;
    } else {
      m += t * i;
    }
    i *= 10;
    n /= 10;
    cnt++;
  }
  cout << m;
  return 0;
}
