#include <bits/stdc++.h>
const int MOD = int(1e9) + 7;
const int N = 1100;
const int MAXN = int(1e6) + int(1e5);
const int iinf = int(1e9) + int(1e5);
const long long linf = (long long)(1e18) + (long long)(1e17);
const double eps = -1e19;
using namespace std;
string second;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> second;
  for (int i = 0; i <= second.size() - 1; i += 1)
    if (second[i] >= '5' && (second[i] < '9' || i > 0))
      second[i] = ('9' - second[i]) + '0';
  cout << second;
}
