#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<int> v;
  while (n != 0) {
    v.push_back(n % 10);
    n /= 10;
  }
  reverse(v.begin(), v.end());
  for (int i = 0; i < (int)v.size(); i++) {
    if (i == 0 and v[i] == 9) continue;
    if (9 - v[i] < v[i]) v[i] = 9 - v[i];
  }
  for (int i = 0; i < (int)v.size(); i++) cout << v[i];
}
