num = list(input())
for i in range(len(num) - 1, -1, -1):
if i == 0 and num[i] == str(9):
continue
if int(num[i]) > 9 - int(num[i]):
num[i] = str(9 - int(num[i]))
num = "".join(num)
print(num)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1000010;
int main()
{
string s;
cin>>s;
for(int i=0;i<s.size();i++)
{
if(i==0)
{
if((s[0]-'0')>=5&&(s[0]-'0')<9)
{
cout<<9-(s[0]-'0');
}
else
{
cout<<s[0];
}
}
else
{
if((s[i]-'0')>=5&&(s[i]-'0')<=9)
{
cout<<9-(s[i]-'0');
}
else
{
cout<<s[i];
}
}
}
return 0;
}
1720A - Burenka Plays with Fractions | 3A - Shortest path of the king |
1720C - Corners | 574A - Bear and Elections |
352B - Jeff and Periods | 1244A - Pens and Pencils |
1670A - Prof Slim | 1189A - Keanu Reeves |
678A - Johny Likes Numbers | 1699C - The Third Problem |
1697D - Guess The String | 754B - Ilya and tic-tac-toe game |
760A - Petr and a calendar | 1573A - Countdown |
166A - Rank List | 1631B - Fun with Even Subarrays |
727A - Transformation from A to B | 822B - Crossword solving |
1623A - Robot Cleaner | 884B - Japanese Crosswords Strike Back |
862B - Mahmoud and Ehab and the bipartiteness | 429A - Xor-tree |
1675C - Detective Task | 950A - Left-handers Right-handers and Ambidexters |
672B - Different is Good | 1C - Ancient Berland Circus |
721A - One-dimensional Japanese Crossword | 1715B - Beautiful Array |
60B - Serial Time | 453A - Little Pony and Expected Maximum |