#include <bits/stdc++.h>   using namespace std;   using ll = long long int;   int gcd(int n, int m) {     if (m == 0) return n;     return gcd(m, n % m);   }   int lcm(int n, int m) { return n * m / gcd(n, m); }   ll fact(ll n) {     if (n == 1 or n == 0)       return 1;     else       return ((n % 1000000007) * (fact(n - 1) % 1000000007)) % 1000000007;   }   template <typename T>   T modpow(T base, T exp) {     base %= 1000000007;     T result = 1;     while (exp > 0) {       if (exp & 1) (result *= base) %= 1000000007;       (base *= base) %= 1000000007;       exp >>= 1;     }     return result;   }   int bin_search(vector<int>& a, int ele) {     int lo = 0, hi = a.size() - 1;     while (lo <= hi) {       int mid = lo + (hi - lo) / 2;       if (mid == 0 or mid == a.size() - 1)         return mid;       else if (a[mid] >= ele and a[mid - 1] < ele)         return mid;       else if (a[mid] >= ele)         hi = mid - 1;       else         lo = mid + 1;     }   }   bool ifPrime(int n) {     for (int i = 2; i <= sqrt(n); i++) {       if (n % i == 0) return 0;     }     return 1;   }   void solve(int testno) {     string s;     cin >> s;     string orig = s;     bool no = 1;     for (char& c : s) {       if (c ==  9  and no) {         no = 0;         continue;       }       no = 0;       if (c -  0  >= 5) {         c =  0  + ( 9  - c);       }     }     cout << s;   }   int32_t main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin.exceptions(ios::badbit | ios::failbit);     int t = 1;     for (int i = 1; i <= t; i++) {       solve(i);     }     return 0;   }   