Luke Skywalker gave Chewbacca an integer number x. Chewbacca isn't good at numbers but he loves inverting digits in them. Inverting digit t means replacing it with digit 9 - t. 

Help Chewbacca to transform the initial number x to the minimum possible positive number by inverting some (possibly, zero) digits. The decimal representation of the final number shouldn't start with a zero.


-----Input-----

The first line contains a single integer x (1 ≤ x ≤ 10^18) — the number that Luke Skywalker gave to Chewbacca.


-----Output-----

Print the minimum possible positive number that Chewbacca can obtain after inverting some digits. The number shouldn't contain leading zeroes.


-----Examples-----
Input
27

Output
22

Input
4545

Output
4444

Difficulty: EASY

Solutions:
n = [int(x) for x in list(input().strip())]
for (i, e) in enumerate(n):
	if i == 0 and e == 9:
		continue
	if e > 4:
		n[i] = 9 - e
print(int(''.join((str(x) for x in n))))


s = list(str(input()))
for i in range(len(s)):
	if i == 0:
		if s[i] == '9':
			continue
	if int(s[i]) >= 5:
		s[i] = str(9 - int(s[i]))
print(''.join(s))


numbers = input()
n = len(numbers)
acc = ''
for i in range(n - 1, -1, -1):
	n = int(numbers[i])
	if n >= 5:
		n = 9 - n
	acc = str(n) + acc
output = numbers[:i] + acc
if output[0] == '0':
	output = '9' + output[1:]
print(output)


digits = list(input())
digits = [int(x) for x in digits]
for i in range(len(digits)):
	if i == 0 and digits[i] == 9:
		pass
	elif digits[i] >= 5:
		digits[i] = 9 - digits[i]
print(''.join([str(x) for x in digits]))


number = input()
answer = int(number)
for i in range(len(number)):
	if not i == len(number) - 1:
		if answer > answer + (9 - int(number[len(number) - i - 1])) * 10 ** i - int(number[len(number) - i - 1]) * 10 ** i:
			answer = answer + (9 - int(number[len(number) - i - 1])) * 10 ** i - int(number[len(number) - i - 1]) * 10 ** i
	if i == len(number) - 1:
		if answer > answer + (9 - int(number[len(number) - i - 1])) * 10 ** i - int(number[len(number) - i - 1]) * 10 ** i and 9 - int(number[len(number) - i - 1]) > 0:
			answer = answer + (9 - int(number[len(number) - i - 1])) * 10 ** i - int(number[len(number) - i - 1]) * 10 ** i
print(answer)


a = input()
if int(a[0]) is not 9:
	print(min(int(a[0]), 9 - int(a[0])), end='')
else:
	print(9, end='')
for i in range(1, len(a)):
	print(min(int(a[i]), 9 - int(a[i])), end='')


t = ''
for i in input():
	if t != '' or int(i) != 9:
		t += [i, str(9 - int(i))][int(i) > 4]
	else:
		t += '9'
print(t)


n = list(input())
l = len(n)
for i in range(1, l):
	if int(n[i]) < 5:
		continue
	else:
		n[i] = str(9 - int(n[i]))
if int(n[0]) != 9 and int(n[0]) >= 5:
	n[0] = str(9 - int(n[0]))
print(''.join(n))


n = input()
new = []
for i in n:
	if int(i) >= 5:
		new.append(str(9 - int(i)))
	else:
		new.append(i)
if new[0] == '0':
	new[0] = '9'
print(''.join(new))


n = list(str(input()))
for (idx, x) in enumerate(n):
	if 9 - int(x) < int(x):
		if idx > 0 or 9 - int(x) != 0:
			n[idx] = str(9 - int(x))
print(int(''.join(n)))


t = input()
i = 0
for k in t:
	if k == '9' and i == 0:
		pass
	elif int(k) > 4:
		t = t[0:i] + str(9 - int(k)) + t[i + 1:]
	else:
		pass
	i += 1
print(int(t))


x = input()
for char in x:
	if int(char) >= 5:
		x = x.replace(char, str(9 - int(char)))
if x[0] == '0':
	x = '9' + x[1:]
print(x)


n = input()
res = ''
for t in range(0, len(n)):
	i = n[t]
	if t == 0:
		if 9 - int(i) > 0:
			if 9 - int(i) < int(i):
				res += str(9 - int(i))
			else:
				res += i
		else:
			res += i
	elif 9 - int(i) > -1:
		if 9 - int(i) < int(i):
			res += str(9 - int(i))
		else:
			res += i
	else:
		res += i
print(res)


numbers = int(input())
numbers = [int(e) for e in str(numbers)]
for x in range(len(numbers)):
	if x == 0:
		if numbers[x] == 9:
			numbers[x] = numbers[x]
		elif 9 - numbers[x] < numbers[x]:
			numbers[x] = 9 - numbers[x]
	elif 9 - numbers[x] < numbers[x]:
		numbers[x] = 9 - numbers[x]
numbers = [str(e) for e in numbers]
numbers = ''.join(numbers)
print(numbers)


x = list(map(int, input()))
for i in range(len(x)):
	if x[i] >= 5 and (not (i == 0 and x[i] == 9)):
		x[i] = 9 - x[i]
print(''.join(list(map(str, x))))


a = ''.join((min(c, str(9 - int(c))) for c in input()))
print(('9' if a[0] == '0' else a[0]) + a[1:])


x = input()
for i in range(len(x)):
	if x[i] >= '5' and (i != 0 or x[i] != '9'):
		x = x[:i] + str(9 - int(x[i])) + x[i + 1:]
print(x)


l = []
for i in input():
	i = min(int(i), 9 - int(i))
	l.append(str(i))
if l[0] == '0':
	l[0] = '9'
print(''.join(l))


string = input()
arr = []
for i in string:
	arr.append(int(i))
arr_inv = []
ans = []
for i in arr:
	arr_inv.append(9 - i)
for i in range(len(arr)):
	if arr_inv[0] == 0:
		ans.append(arr[i])
		arr_inv[0] = 2
	elif arr_inv[i] < arr[i]:
		ans.append(arr_inv[i])
	else:
		ans.append(arr[i])
ans_str = []
for i in ans:
	ans_str.append(str(i))
final = ''
for i in ans_str:
	final = final + i
print(final)


n = list(map(int, input()))
l = []
for i in n:
	l.append(min(i, 9 - i))
if l[0] == 0:
	l[0] = 9
print(int(''.join(map(str, l))))


import sys
x = int(input())
g = len(str(x)) - 1
l = g
y = int(pow(10, l))
number = 0
while l >= 0:
	digit = int(x / y)
	if digit == 10:
		digit = 9
	x = int(x - digit * y)
	if 9 - digit < digit:
		digit = 9 - digit
		if l == g and digit == 0:
			digit = 9 - digit
	number += digit * y
	y = int(y / 10)
	l -= 1
print(number)


a = input()
b = ''
for x in range(len(a)):
	digit = int(a[x])
	if 9 - digit < digit and digit != 9 or (digit == 9 and x != 0):
		digit = 9 - digit
	b += str(digit)
print(b)


x = list(str(input()))
for i in range(len(x)):
	if int(x[i]) >= 5:
		x[i] = 9 - int(x[i])
if x[0] == 0:
	x[0] = 9

def convert(list):
	res = int(''.join(map(str, list)))
	return res
list = x
print(convert(list))


n = input()
rep = {'1': '8', '2': '7', '3': '6', '4': '5', '5': '4', '6': '3', '7': '2', '8': '1', '9': '0', '0': '9'}
num = ''
for i in range(len(n)):
	if i == 0 and n[i] == '9':
		num = num + '9'
		continue
	if int(rep[str(n[i])]) < int(n[i]):
		num = num + rep[str(n[i])]
	else:
		num = num + n[i]
print(num)


x = int(input())
digit = [int(i) for i in str(x)]
n = len(digit)
if digit[0] < 9 and digit[0] > 4:
	digit[0] = 9 - digit[0]
for i in range(1, n):
	if digit[i] > 4:
		digit[i] = 9 - digit[i]
for i in digit:
	print(i, end='')


k = input()
one = [int(i) for i in k]
for i in range(1, len(one)):
	if 9 - one[i] < one[i]:
		one[i] = 9 - one[i]
	else:
		continue
if 9 - one[0] != 0 and 9 - one[0] < one[0]:
	one[0] = 9 - one[0]
for i in one:
	print(i, end='')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def abs(x):
	return x if x >= 0 else -x

def sumelem(x, start, end):
	sum = 0
	for i in range(start, end + 1):
		sum += x[i]
	return sum
for t in range(1):
	n = input()
	for i in range(len(n)):
		if int(n[i]) >= 5:
			str_temp = n[:i] + str(9 - int(n[i])) + n[i + 1:]
			n = str_temp
	if int(n[0]) == 0:
		n = str(9) + n[1:]
	print(n)


a = input('')
counter = 0
strN = ''
for i in a:
	num = int(i)
	if counter == 0:
		if num == 9 or 9 - num > num:
			strN = strN + i
		else:
			strN = strN + str(9 - num)
	elif 9 - num > num:
		strN = strN + i
	else:
		strN = strN + str(9 - num)
	counter = counter + 1
print(int(strN))


n = str(input())
f = ''
count = 0
for i in n:
	g = int(i)
	if count == 0 and g == 9:
		f = f + i
	else:
		y = 9 - g
		x = str(y)
		if g > y:
			f = f + x
		else:
			f = f + i
	count = count + 1
print(f)


a = list(map(int, list(input().rstrip())))
res = ''
t = 0
if a[0] == 9:
	res += '9'
	t = 1
for i in a[t:]:
	if i >= 5:
		res += str(9 - i)
	else:
		res += str(i)
print(res)


inverse = {digit: digit for digit in '01234'}
for digit in '56789':
	inverse[digit] = str(9 - int(digit))
x = input()
print(x[0] if x[0] == '9' and x[0] else inverse[x[0]], end='')
for digit in x[1:]:
	print(inverse[digit], end='')


st = input()
st2 = []
for i in range(len(st)):
	if int(st[i]) > 4:
		if i != 0 or int(st[i]) != 9:
			st2.append(9 - int(st[i]))
		else:
			st2.append(int(st[i]))
	else:
		st2.append(int(st[i]))
for i in st2:
	print(i, end='')


n = input()
l = ''
s = 0
for i in n:
	i = int(i)
	if 9 - i < i and 9 - i >= 0:
		if 9 - i == 0 and s == 0:
			s += 1
			l += str(i)
			continue
		l += str(9 - i)
	else:
		l += str(i)
	s += 1
print(l)


x = int(input())
ans = 0
for c in str(x):
	d = int(c)
	inv = 9 - d
	if inv < d:
		if ans * 10 + inv > 0:
			ans = ans * 10 + inv
		else:
			ans = ans * 10 + d
	else:
		ans = ans * 10 + d
print(ans)


n = input()
for i in range(len(n)):
	if i == 0 and n[i] == '9':
		print(9, end='')
	elif int(n[i]) > 4:
		print(9 - int(n[i]), end='')
	else:
		print(int(n[i]), end='')


import sys
num = list(map(int, list(sys.stdin.readline().strip())))
for i in range(len(num)):
	if num[i] >= 5 and (num[i] != 9 or i):
		num[i] = 9 - num[i]
print(''.join(map(str, num)))


def invert(digit):
	if digit > 4:
		return 9 - digit
	else:
		return digit
string = input()
firstDigit = True
for letter in string:
	digit = int(letter)
	if firstDigit == True:
		if digit == 9:
			print(9, end='')
		else:
			print(invert(digit), end='')
		firstDigit = False
	else:
		print(invert(digit), end='')


def ans():
	inp = [int(i) for i in input()]
	for i in range(len(inp)):
		if inp[i] > 4:
			inp[i] = 9 - inp[i]
	if inp[0] == 0:
		inp[0] = 9
	inp = [str(i) for i in inp]
	print(''.join(inp))
	return
ans()


x = input()
c = 0
if int(x[0]) == 9:
	c = 9
else:
	c = min(int(x[0]), 9 - int(x[0]))
for i in range(len(x)):
	if i != 0:
		a = int(x[i])
		b = min(a, 9 - a)
		c = c * 10 + b
print(c)


n = input()
b = ''
for i in range(len(n)):
	if 9 - int(n[i]) < int(n[i]):
		if len(b) == 0 and 9 - int(n[i]) == 0:
			b += n[i]
		else:
			b = b + str(9 - int(n[i]))
	else:
		b += n[i]
print(b)


def count(num):
	if num == 0:
		return 0
	res = ''
	for (i, n) in enumerate(str(num)):
		if n == '9' and i == 0:
			res += n
		else:
			inverted = 9 - int(n)
			if inverted < 0:
				inverted = 10
			res += str(min(int(n), inverted))
	return int(res)
try:
	num = int(input())
	print(count(num))
except:
	print(0)


s = input()
arr = list(map(int, list(s)))
for i in range(len(arr)):
	if i == 0 and arr[i] == 9:
		continue
	if arr[i] > 4:
		arr[i] = 9 - arr[i]
s = list(map(str, arr))
x = int(''.join(s))
print(x)


a = input()
z = a
b = list(a)
r = 0
p = ''
lst1 = []
for k in a:
	t = int(k)
	y = 9 - t
	if y < t:
		m = a.replace(str(t), str(y))
		r = 1
	if r == 1:
		a = m
	else:
		a = a
if r == 1 and a[0] != '0':
	print(a)
elif a[0] == '0':
	w = list(m)
	w.remove(m[0])
	for y in w:
		p = p + y
	print(z[0] + p)
else:
	print(z)


n = int(input())
string = str(n)
l = len(string)
new = ''
for i in range(l):
	if i == 0 and string[0] == '9':
		new = new + '9'
	elif int(string[i]) > 4:
		new = new + str(9 - int(string[i]))
	else:
		new = new + string[i]
print(new)


x = input()
ans = ''
hasNine = False
for i in range(len(x)):
	if int(x[i]) > 4:
		if x[i] == '9' and i == 0:
			ans += x[i]
		else:
			ans += str(9 - int(x[i]))
	else:
		ans += x[i]
print(ans)


def print_arr(arr):
	print(*arr, sep='')
x = int(input())
num = []
while x > 0:
	dig = x % 10
	if dig > 4 and x != 9:
		dig = 9 - dig
	num.insert(0, dig)
	x //= 10
print_arr(num)


x = input()
output = ''
if 4 < int(x[0]) < 9:
	output += str(9 - int(x[0]))
else:
	output += x[0]
for i in range(1, len(x)):
	j = int(x[i])
	if j > 4:
		output += str(9 - j)
	else:
		output += str(j)
print(output)


num = list(input())
for i in range(len(num)):
	num[i] = int(num[i])
	if i != 0 or (i == 0 and num[i] != 9):
		num[i] = min(num[i], 9 - num[i])
print(''.join([str(num[i]) for i in range(len(num))]))


import math
n = input()
count = 0
for i in n:
	if ord(i) == 57 and count == 0:
		print(i, end='')
	elif ord(i) > 52:
		print(57 - ord(i), end='')
	else:
		print(i, end='')
	count += 1


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
x = insr()
li = []
li2 = []
for i in range(0, len(x)):
	b = int(x[i])
	if i == 0 and b == 9:
		li2.append(b)
		continue
	else:
		a = 9 - b
		if a < b:
			li2.append(a)
		else:
			li2.append(b)
for i in li2:
	print(i, end='')


s = [int(_) for _ in list(input())]
for i in range(len(s)):
	if 9 - s[i] < s[i]:
		if i == 0 and 9 - s[i] == 0:
			continue
		s[i] = 9 - s[i]
print(int(''.join([str(_) for _ in s])))


n = input()
res = ''
for x in n:
	if int(x) >= 5:
		res += str(9 - int(x))
	else:
		res += x
if res[0] == '0':
	res = n[0] + res[1:]
print(res)


a = input()
if a[0] == '9':
	print(9, end='')
else:
	print(min(int(a[0]), 9 - int(a[0])), end='')
for i in range(1, len(a)):
	b = int(a[i])
	print(min(b, 9 - b), end='')


x = list(input())
if int(x[0]) != 9 and int(x[0]) > 4:
	x[0] = 9 - int(x[0])
for i in range(1, len(x)):
	if int(x[i]) > 4:
		x[i] = 9 - int(x[i])
for i in x:
	print(i, end='')


n = input()
leng = len(n)
for i in range(leng):
	if i is 0 and n[i] is '9':
		continue
	elif n[i] > '4':
		n = n.replace(n[i], str(9 - int(n[i])))
n = [i for i in n]
if n[0] is '0':
	n[0] = '9'
print(''.join(n))


a = input()
b = ''
g = 0
for i in a:
	g += 1
	p = int(i)
	q = 9 - p
	if g == 1 and q == 0:
		b = b + str(9)
	elif p < q:
		b = b + i
	else:
		b = b + str(q)
print(int(b))


s = input()
a = list(s)
for i in range(len(a)):
	a[i] = int(a[i])
if len(a) == 1:
	if 4 < a[0] and a[0] < 9:
		a[0] = 9 - a[0]
else:
	for i in range(len(a)):
		if a[i] > 4:
			a[i] = 9 - a[i]
	if a[0] == 0:
		a[0] = 9
for i in range(len(a)):
	print(a[i], end='')


N = input()
startIndex = 0
if N[0] == '9':
	print(9, end='')
	startIndex = 1
for index in range(startIndex, len(N)):
	if int(N[index]) > 4:
		print(9 - int(N[index]), end='')
	else:
		print(N[index], end='')


n = input()
res = ''
for t in n:
	if 9 - int(t) in range(0, 5):
		res += str(9 - int(t))
	else:
		res += t
if res[0] == '0':
	res = res.replace('0', '9', 1)
print(res)


a = input()
if 4 < int(a[0]) < 9:
	a = str(9 - int(a[0])) + a[1:]
for i in range(1, len(a)):
	if 4 < int(a[i]) <= 9:
		a = a[:i] + str(9 - int(a[i])) + a[i + 1:]
print(a)


def main():
	n = int(input())
	s = []
	while n > 0:
		k = n % 10
		if k <= 4 or (n < 10 and k == 9):
			s.append(k)
		else:
			s.append(9 - k)
		n //= 10
	for i in range(len(s) - 1, -1, -1):
		n *= 10
		n += s[i]
	print(n)
main()


def invert(num):
	num = str(num)
	num = list(num)
	res = ''
	for i in range(0, len(num)):
		if int(num[i]) > 4:
			if i == 0 and num[i] == '9':
				res += num[i]
				continue
			else:
				num[i] = str(9 - int(num[i]))
		res += num[i]
	return res
n = int(input())
s1 = invert(n)
print(s1)


n = list(input())
b = list(map(int, n))
s = ''
for i in b:
	if i > 4:
		s += str(9 - i)
	else:
		s += str(i)
if s[0] == '0':
	print('9' + s[1:])
else:
	print(s)


s = input()
for (i, c) in enumerate(s):
	c = int(c)
	if i == 0 and c == 9:
		print(9, end='')
	else:
		print(min(c, 9 - c), end='')


num = list(map(int, input()))
rec = []
if num[0] == 9:
	rec.append(9)
elif num[0] >= 5:
	x = 9 - num[0]
	rec.append(x)
else:
	rec.append(num[0])
for x in range(1, len(num)):
	if num[x] >= 5:
		num[x] = 9 - num[x]
	rec.append(num[x])
print(''.join(map(str, rec)))


s = input()
x = s[0]
for i in s:
	if int(i) > 4:
		s = s.replace(i, str(9 - int(i)))
if s[0] == '0':
	s = x + s[1:]
print(s)


def solution():
	n = input()
	result = ''
	current = n[0]
	if not int(current) == 9:
		if int(current) >= 5:
			current = str(9 - int(current))
	result += current
	for i in range(1, len(n)):
		current = n[i]
		if int(current) >= 5:
			current = str(9 - int(current))
		result += current
	print(result)
solution()


Numbers = [0, 1, 2, 3, 4, 4, 3, 2, 1, 0]
s = input()
p = ''
for i in s:
	n = int(i)
	p += str(Numbers[n])
if p[0] == '0':
	p = '9' + p[1:]
print(int(p))


i = input('')
i = list(i)
for j in range(len(i)):
	i[j] = int(i[j])
for g in range(len(i)):
	if i[g] > 4:
		invertedval = 9 - i[g]
		i[g] = invertedval
if i[0] == 0:
	i[0] = 9
print(*i, sep='')


x = list(input())
ans = ''
j = 0
for i in x:
	if int(i) > 4:
		if j == 0 and int(i) == 9:
			ans += i
		else:
			ans += str(9 - int(i))
	else:
		ans += i
	j += 1
print(ans)


x = int(input(''))
d = x
l = 0
n = []
p = 0
f = 0
while d >= 1:
	l += 1
	d = d // 10
else:
	for i in range(l, 0, -1):
		p = 10 ** (i - 1)
		d = x // p
		f = d % 10
		if f <= 4:
			n.append(f)
		elif f == 9 and i == l:
			n.append(f)
		else:
			n.append(9 - f)
	num = int(''.join(map(str, n)))
	print(num)


n = list(str(input()))
n1 = n
for i in range(len(n)):
	if int(n[i]) > 4:
		n[i] = str(9 - int(n[i]))
s = ''
k = 0
for j in range(len(n)):
	if j == 0:
		if n[0] != '0':
			s += n[j]
		else:
			s = '9'
	else:
		s += n[j]
print(s)


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = []
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors.append(i)
			n //= i
		i += 1
	if n > 1:
		factors.append(n)
	return factors

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def main():
	s = input()
	n = len(s)
	res = ''
	for i in range(n):
		if int(s[i]) < 5:
			res += s[i]
		else:
			inv = 9 - int(s[i])
			if inv == 0 and i == 0:
				res += s[i]
			else:
				res += str(inv)
	print(int(res))
t = 1
for _ in range(t):
	main()


import math
from queue import LifoQueue

def inp():
	return int(input().strip())

def inlist():
	return list(map(int, input().strip().split()))

def instr():
	s = input().strip()
	return list(s[:len(s)])

def invr():
	return map(int, input().strip().split())
n = input()
res = ''
f = 1
for i in range(len(n)):
	a = int(n[i])
	if a > 4:
		a = 9 - a
		if a == 0 and len(res) == 0:
			res += '9'
		else:
			res += str(a)
	elif a == 0 and len(res) == 0:
		res += 9
	else:
		res += str(a)
print(res)


x = input()
ans = ''
for i in range(len(x)):
	if (int(x[0]) != 9 or i != 0) and int(x[i]) > 4:
		ans += str(9 - int(x[i]))
	elif int(x[i]) == 9 and i == 0:
		ans += str(9)
	else:
		ans += x[i]
print(ans)


n = input()
res = str(9 - int(n[0])) if int(n[0]) in [5, 6, 7, 8] else n[0]
for digit in n[1:]:
	res += str(9 - int(digit)) if int(digit) in [5, 6, 7, 8, 9] else digit
print(res)


N = input()
n = []
for i in range(len(N)):
	if i == 0 and N[i] == '9':
		n.append(9)
	elif int(N[i]) >= 5:
		n.append(9 - int(N[i]))
	else:
		n.append(int(N[i]))
for i in range(len(N)):
	print(n[i], end='')


n = input()
n = list(n)
if n[0] != '9':
	if 9 - int(n[0]) < int(n[0]):
		n[0] = str(9 - int(n[0]))
for i in range(1, len(n)):
	if 9 - int(n[i]) < int(n[i]):
		n[i] = str(9 - int(n[i]))
print(''.join(n))


a = input()
r = ''
if int(a[0]) > 4 and int(a[0]) <= 8:
	b = 9 - int(a[0])
	r += str(b)
else:
	r += a[0]
for i in range(1, len(a)):
	if int(a[i]) > 4:
		b = 9 - int(a[i])
		r += str(b)
	else:
		r += a[i]
print(r)


n = input()
s = ''
for i in range(len(n)):
	t = int(n[i])
	if 0 <= 9 - t < t:
		if i == 0 and 9 - t == 0:
			s = s + n[i]
		else:
			s = s + str(9 - t)
	else:
		s = s + n[i]
print(int(s))


x = list(input())
i = 0
while i < len(x):
	if i == 0:
		if 4 < int(x[i]) < 9:
			x[i] = str(9 - int(x[i]))
	elif int(x[i]) > 4:
		x[i] = str(9 - int(x[i]))
	i += 1
exp = ''.join(x)
print(exp)


x = input()
c = []
for i in range(len(x)):
	if x[i] >= '5':
		c.append(9 - int(x[i]))
	else:
		c.append(int(x[i]))
if c[0] == 0:
	c[0] = 9
for i in c:
	print(int(i), end='')


a = ''.join(([chr(105 - ord(d)), d][d < '5'] for d in input()))
print(['9' + a[1:], a][a[0] != '0'])


n = list(map(int, [i for i in input()]))
for i in range(len(n)):
	if 9 - n[i] < n[i]:
		if 9 - n[i] == 0 and i == 0:
			continue
		n[i] = 9 - n[i]
print(*n, sep='')


a = str(input())
b = list(a)
b = list(map(int, b))
if 9 > b[0] >= 5:
	b[0] = 9 - b[0]
for i in range(1, len(b)):
	if b[i] >= 5:
		b[i] = 9 - b[i]
c = list(map(str, b))
d = ''.join(c)
print(d)


s = input()
k = int(s[0])
if k != 9:
	k = min(k, 9 - k)
print(k, end='')
for i in range(1, s.__len__()):
	k = int(s[i])
	k = min(k, 9 - k)
	print(k, end='')
print()


input = input()
str_var = ''
count = 0
for i in str(input):
	if count == 0 and int(i) == 9:
		i = 9
	elif int(i) > 4:
		i = 9 - int(i)
	str_var += str(i)
	count += 1
int_var = int(str_var)
print(int_var)


a = list(input())
for i in range(len(a)):
	if 9 - int(a[i]) < int(a[i]):
		a[i] = str(9 - int(a[i]))
if a[0] == '0':
	a[0] = str(9)
s = ''
for i in a:
	s += i
print(int(s))


s = str(input())
n = len(s)
x = [''] * n
for i in range(n):
	x[i] = s[i]
for i in range(n):
	if int(s[i]) * 2 > 9:
		if i == 0 and s[i] == '9':
			x[i] = '9'
		else:
			x[i] = str(9 - int(s[i]))
print(''.join(x))


def f(x):
	return min(9 - x, x)
s = list(map(int, input()))
if s[0] != 9:
	s[0] = f(s[0])
if len(s) == 1:
	print(s[0])
	exit(0)
for n in range(1, len(s)):
	s[n] = f(s[n])
for n in s:
	print(n, end='')


s = list(input())
for i in range(len(s)):
	if i == 0:
		if s[i] > '4' and s[i] < '9':
			s[0] = str(9 - int(s[i]))
	elif s[i] > '4':
		s[i] = str(9 - int(s[i]))
print(''.join(s))


n = list(map(int, list(input())))
b = [5, 6, 7, 8, 9]
if n[0] in b[:-1]:
	n[0] = 9 - n[0]
for i in range(1, len(n)):
	if n[i] in b:
		n[i] = 9 - n[i]
print(''.join(map(str, n)))


n = list(map(int, input()))
for i in range(len(n)):
	if 9 > n[i] > 4 or (n[i] > 4 and i != 0):
		n[i] = 9 - n[i]
print(''.join(map(str, n)))


s = input()
res = ''
if s[0] == '9':
	res += s[0]
else:
	res += min(s[0], str(9 - int(s[0])))
for i in range(1, len(s)):
	res += min(s[i], str(9 - int(s[i])))
print(res)


def invent(x):
	if 9 - x < x:
		return 9 - x
	else:
		return x
k = input()
ans = ''
if k[0] == '9':
	ans += '9'
else:
	ans += str(invent(int(k[0])))
for i in range(1, len(k)):
	ans += str(invent(int(k[i])))
print(ans)


n = list(input())
for i in range(len(n)):
	if int(n[i]) == 9 and i != 0:
		n[i] = str(0)
	elif int(n[i]) == 9 and i == 0:
		n[i] = n[i]
	elif int(n[i]) >= 5 and int(n[i]) <= 9:
		n[i] = str(9 - int(n[i]))
print(''.join(n))


from sys import stdin
input = stdin.readline
t = input()[:-1]
if t[0] == '9':
	total = '9'
else:
	ti = int(t[0])
	total = str(min(9 - ti, ti))
for i in range(1, len(t)):
	ti = int(t[i])
	check = str(min(9 - ti, ti))
	if check:
		total += check
	else:
		total += ti
print(total)


n = int(input())
m = n
i = 0
while m:
	s = n - pow(10, i) * (m % 10)
	if s + pow(10, i) * abs(9 - m % 10) < n:
		if not (m // 10 == 0 and m % 10 == 9):
			n = s + pow(10, i) * abs(9 - m % 10)
	i += 1
	m = m // 10
print(n)


n = input()
if n[0] != '9' and int(n[0]) > 9 - int(n[0]):
	print(9 - int(n[0]), end='')
else:
	print(n[0], end='')
for i in range(1, len(n)):
	t = int(i)
	if int(n[i]) > 9 - int(n[i]):
		print(9 - int(n[i]), end='')
	else:
		print(int(n[i]), end='')


l = list(input())
for x in range(1, len(l)):
	b = int(l[x])
	l[x] = str(min(b, 9 - b))
if l[0] != '9':
	l[0] = str(min(int(l[0]), 9 - int(l[0])))
print(''.join(l))


num = list(input())
a = ''
for (i, n) in enumerate(num):
	if i == 0 and n == '9':
		a += '9'
		continue
	if n == '0' or n == '1' or n == '2' or (n == '3') or (n == '4'):
		a += n
		continue
	if n == '5':
		a += '4'
	elif n == '6':
		a += '3'
	elif n == '7':
		a += '2'
	elif n == '8':
		a += '1'
	else:
		a += '0'
print(int(a))


a = input()
b = list(a)
c = []
for i in range(len(b)):
	if i == 0:
		if 9 - int(b[0]) != 0 and 9 - int(b[i]) < int(b[i]):
			print(9 - int(b[0]), end='')
		else:
			print(int(b[0]), end='')
	elif 9 - int(b[i]) < int(b[i]):
		print(int(9 - int(b[i])), end='')
	else:
		print(int(b[i]), end='')


n = input()
for c in range(len(n)):
	if c == 0 and int(n[0]) == 9:
		print(n[c], end='')
	elif int(n[c]) < 9 - int(n[c]):
		print(n[c], end='')
	else:
		print(str(9 - int(n[c])), end='')


n = int(input())
s = []
while n > 0:
	d = n % 10
	invD = 9 - d
	n //= 10
	s.append(str(invD) if invD < d else str(d))
s.reverse()
if s[0] == '0':
	s[0] = '9'
print(''.join(s))


a = list(input())
no = ['1', '2', '3', '4', '0']
for j in range(len(a)):
	if j == 0:
		if a[j] == '9':
			pass
		elif a[j] in no:
			pass
		else:
			a[j] = str(9 - int(a[j]))
	elif a[j] in no:
		pass
	else:
		a[j] = str(9 - int(a[j]))
print(''.join(a))


n = list(input())
s = []
for i in n:
	s.append(min(int(i), 9 - int(i)))
if s[0] < 1:
	s[0] = 9
print(''.join(map(str, s)))


d = int(input())
x = 0
i = 1
while d > 9:
	x += i * min(d % 10, 9 - d % 10)
	i *= 10
	d //= 10
x += 9 * i if d == 9 else i * min(9 - d, d)
print(int(x))


a = input()
dic = {'5': '4', '6': '3', '7': '2', '8': '1', '9': '0'}
if a[0] != '9' and a[0] in dic:
	a = dic[a[0]] + a[1:]
for i in range(1, len(a)):
	if a[i] in dic:
		a = a[:i] + dic[a[i]] + a[i + 1:]
print(a)


n = int(input())
l = []
while n > 0:
	r = n % 10
	if 9 - r < r and (n // 10 > 0 or 9 - r != 0):
		l.append(9 - r)
	else:
		l.append(r)
	n = n // 10
for i in range(len(l) - 1, -1, -1):
	print(l[i], end='')


s = input()
l = s
for i in range(len(s)):
	if int(s[i]) > 4 and (not (i == 0 and s[i] == '9')):
		s = s[:i] + str(9 - int(s[i])) + s[i + 1:]
if int(s) == 0:
	s = l
	for i in range(len(s) - 1):
		if int(s[i]) > 4:
			s = s[:i] + str(9 - int(s[i])) + s[i + 1:]
print(s)


number = list(map(int, list(input())))
for i in range(len(number)):
	if number[i] >= 5:
		number[i] = 9 - number[i]
if number[0] == 0:
	number[0] = 9
number = list(map(str, number))
print(''.join(number))


s = input()
s = s[0] + s[1:].replace('9', '0')
print(''.join(list(map(lambda x: str(9 - int(x)) if int(x) >= 5 and int(x) != 9 else x, s))))


x = [int(i) for i in input()]
for i in range(len(x)):
	x[i] = min(x[i], 9 - x[i])
if x[0] == 0:
	x[0] = 9
print(''.join([str(i) for i in x]))


a = input()
new = ''
cnt = 0
for i in a:
	tmp = int(i)
	if tmp > 4 and tmp != 9 or (tmp == 9 and len(a) > 1 and (cnt != 0)):
		new += str(9 - tmp)
	else:
		new += i
	cnt += 1
print(new)


x = [int(digit) for digit in input().rstrip()]
for i in range(len(x)):
	x[i] = 9 - x[i] if x[i] >= 5 and (not (i == 0 and x[i] == 9)) else x[i]
print(''.join([str(c) for c in x]))


import sys
import math
input = sys.stdin.readline
x = input().strip()
ans = ''
if x[0] != '9' and int(x[0]) >= 5:
	ans += str(9 - int(x[0]))
else:
	ans += x[0]
for i in range(1, len(x)):
	if int(x[i]) >= 5:
		ans += str(9 - int(x[i]))
	else:
		ans += x[i]
print(ans)


n = input()
inv = ''
for (idx, i) in enumerate(n):
	i = int(i)
	if i >= 5:
		if idx != 0 or i != 9:
			i = 9 - i
	inv += str(i)
print(inv)


sn = input()
if sn[0] == '9':
	print(9, end='')
	sn = sn[1:]
for e in sn:
	if int(e) > 4:
		print(9 - int(e), end='')
	else:
		print(e, end='')
print()


s = input()
j = 0
if s[0] == '9':
	print(9, sep='', end='')
	j = 1
for i in range(j, len(s)):
	print(min(9 - int(s[i]), int(s[i])), sep='', end='')


x = int(input())
s = ''
count = 1
mod = x // 10
while mod > 0:
	count = count + 1
	mod = mod // 10
for i in range(1, count, 1):
	if x % 10 > 4:
		s = str(9 - x % 10) + s
	if x % 10 < 5:
		s = str(x % 10) + s
	x = x // 10
if x == 9:
	s = str(9) + s
elif x > 4:
	s = str(9 - x % 10) + s
else:
	s = str(x % 10) + s
p = int(s)
print(p)


n = int(input())
l = [i for i in str(n)]
m = []
for l in l:
	m.append(min(int(l), 9 - int(l)))
if m[0] == 0:
	print('9' + ''.join((str(i) for i in m[1:])))
else:
	print(''.join((str(i) for i in m)))


s = input()
sol = ''
for i in range(len(s)):
	if i == 0 and s[i] == '9':
		sol += '9'
		continue
	sol += str(min(int(s[i]), 9 - int(s[i])))
print(sol)


n = input()
res = ''
if n.startswith('9'):
	res = '9'
	n = n[1:]
for i in n:
	if int(i) >= 5:
		res += str(9 - int(i))
	else:
		res += i
print(res)


n = input()
d = ''
a = False
b = True
for x in range(len(n)):
	if n[x] == '9' and x == 0:
		d += n[x]
	elif int(n[x]) >= 5:
		d += str(9 - int(n[x]))
	else:
		d += n[x]
print(d)


n = input()
l = []
for i in n:
	if i <= '4':
		l.append(i)
		continue
	l.append(str(9 - int(i)))
if l[0] == '0':
	l[0] = '9'
print(''.join(l))


n = list(map(int, list(input())))
for i in range(len(n)):
	if n[i] > 4:
		n[i] = 9 - n[i]
if n[0] < 1:
	n[0] = 9
[print(i, end='') for i in n]


n = str(input())
for i in range(10):
	if i > 9 - i:
		n = n.replace(str(i), str(9 - i))
if n[0] == '0':
	n = '9' + n[1:]
print(int(n))


n = [int(x) for x in input()]
len = len(n)
i = 0
while i < len:
	if n[i] > 9 - n[i]:
		if i != 0 or n[i] != 9:
			n[i] = 9 - n[i]
	print(n[i], end='')
	i += 1


s = input()
l = list(map(int, s))
lst = len(l)
for i in range(lst):
	l[i] = min(9 - l[i], l[i])
	if l[i] == 0:
		if i == 0:
			l[i] = 9
for i in range(lst):
	print(l[i], end='')


n = input()
arr = []
for i in range(len(n)):
	if int(n[i]) > 4:
		if i == 0 and int(n[i]) == 9:
			arr.append(int(n[i]))
		else:
			arr.append(9 - int(n[i]))
	else:
		arr.append(int(n[i]))
for i in arr:
	print(i, end='')


x = input()
y = int(x)
for q in range(len(x)):
	s = int(x[q])
	s = 9 - s
	if s == 0 and q == 0:
		continue
	elif s < int(x[q]):
		x = x[:q] + str(s) + x[q + 1:]
print(x)


n = input()
ans = ''
for i in range(len(n)):
	if i == 0 and 9 - int(n[i]) == 0:
		ans += n[i]
		continue
	if 9 - int(n[i]) < int(n[i]):
		ans += str(9 - int(n[i]))
	else:
		ans += n[i]
print(ans)


num = input()
if int(num[0]) > 4 and 9 - int(num[0]) != 0:
	result = str(9 - int(num[0]))
else:
	result = num[0]
for i in num[1:]:
	if int(i) > 4:
		result += str(9 - int(i))
	else:
		result += i
print(result)


x = [int(ch) for ch in input()]
sol = []
for i in range(len(x)):
	el = x[i]
	if i == 0 and el == 9:
		sol.append(9)
	elif el < 5:
		sol.append(el)
	elif el >= 5:
		sol.append(9 - el)
print(''.join(map(str, sol)))


number = input()

def inverting(num):
	if num in range(5, 10):
		return 9 - num
	return num
inverted_number = [str(inverting(int(i))) for i in number]
if inverted_number[0] == '0':
	inverted_number[0] = '9'
print(''.join(inverted_number))


x = input()
slon = ''
for i in range(1, len(x)):
	inverted = ord('9') - ord(x[i])
	if x[i] < '5':
		slon += chr(int(x[i]) + 48)
	else:
		slon += chr(inverted + 48)
inverted = ord('9') - ord(x[0])
if inverted == 0 or int(x[0]) <= int('4'):
	print(x[0], end='')
else:
	print(inverted, end='')
print(slon)


a = input()
ans = ''
for i in range(1, len(a)):
	if int(a[i]) >= 5:
		ans += str(9 - int(a[i]))
	else:
		ans += a[i]
if int(a[0]) >= 5:
	if a[0] != '9':
		ans = str(9 - int(a[0])) + ans
if int(a[0]) < 5 or int(a[0]) == 9:
	ans = a[0] + ans
print(ans)


s = input()
l = len(s)
if s[0] == '9':
	n = s[0]
elif int(s[0]) > 4:
	n = str(9 - int(s[0]))
else:
	n = s[0]
for i in range(1, l):
	if int(s[i]) > 4:
		n += str(9 - int(s[i]))
	else:
		n += s[i]
print(n)


x = list(input())
z = 0
while z < len(x):
	if z == 0:
		if int(x[z]) > 4 and int(x[z]) < 9:
			x[z] = 9 - int(x[z])
	if z != 0:
		if int(x[z]) > 4 and int(x[z]) <= 9:
			x[z] = 9 - int(x[z])
	z += 1
z = 0
while z < len(x):
	print(x[z], end='')
	z += 1


from math import cos, e
import bisect as bs
from math import *

def pro(arr):
	n = len(arr)
	for i in range(n):
		arr[i] = int(arr[i])
	ans = 0
	if arr[0] != 9:
		ans = ans + min(arr[0], 9 - arr[0])
	else:
		ans = ans + arr[0]
	k = 10
	for i in range(1, n):
		ans = ans * 10 + min(arr[i], 9 - arr[i])
	print(ans)
t = 1
for i in range(t):
	n = input()
	pro(list(n))


import math
n = int(input())
size = 1
dup = n
while dup // 10 != 0:
	size += 1
	dup //= 10
result = 0
count = 1
base = 1
while True:
	if n % 10 == 9 and count == size:
		dig = n % 10
	elif n % 10 >= 5:
		dig = 9 - n % 10
	else:
		dig = n % 10
	result += dig * base
	base *= 10
	count += 1
	n = n // 10
	if n == 0:
		break
print(int(result))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	s = S()
	r = []
	for i in range(len(s)):
		c = int(s[i])
		if i == 0 and c == 9:
			r.append(c)
		else:
			r.append(min(c, 9 - c))
	return ''.join(map(str, r))
print(main())


a = []
for (i, d) in enumerate(map(int, input())):
	if i == 0 and d == 9:
		a.append(d)
	else:
		a.append(min(d, 9 - d))
print(''.join(map(str, a)))


s = input()
s1 = ''
x = int(s[0])
if 9 - x < x and 9 - x != 0:
	s1 = s1 + str(9 - x)
else:
	s1 = s1 + str(x)
for i in range(1, len(s)):
	x = int(s[i])
	if 9 - x < x:
		s1 = s1 + str(9 - x)
	else:
		s1 = s1 + str(x)
print(s1)


x = int(input())
y = str(x)
b = ''
for i in range(len(y)):
	a = int(y[i])
	if i == 0 and a == 9:
		b += str(9)
		continue
	if 9 - a < a:
		x = 9 - a
		b += str(x)
	else:
		x = a
		b += str(x)
print(b)


n = input().strip()
if n[0] == '9':
	ans = '9'
else:
	ans = str(min(9 - int(n[0]), int(n[0])))
for i in range(1, len(n)):
	ans += str(min(9 - int(n[i]), int(n[i])))
print(ans)


n = input()
m = ''
for i in range(len(n)):
	m += '9' if i == 0 and n[0] == '9' else min(str(9 - int(n[i])), n[i])
print(m)


n = [x for x in input()]
for i in range(len(n)):
	d = int(n[i])
	if i == 0 and d == 9:
		continue
	if 9 - d < d:
		n[i] = str(9 - d)
print(int(''.join(n)))


from sys import stdin
s = stdin.readline().rstrip()
t = ''
n = len(s)
for i in range(n):
	if i == 0:
		if int(s[i]) > 4 and int(s[i]) < 9:
			t += str(9 - int(s[i]))
		else:
			t += s[i]
	elif int(s[i]) > 4:
		t += str(9 - int(s[i]))
	else:
		t += s[i]
print(t)


ii = input()
if ii[0] == '9':
	e = '9'
	ii = ii[1:]
else:
	e = ''
for i in ii:
	if int(i) > 4:
		e += str(9 - int(i))
	else:
		e += i
print(e)


n = input()
answer = ''
if n[0] == '9':
	answer += '9'
	for i in range(1, len(n)):
		if 9 - int(n[i]) < int(n[i]):
			answer += str(9 - int(n[i]))
		else:
			answer += n[i]
else:
	for i in range(len(n)):
		if 9 - int(n[i]) < int(n[i]):
			answer += str(9 - int(n[i]))
		else:
			answer += n[i]
print(answer)


import functools

def integerdigits(n):
	return [int(i) for i in str(n)]

def fromdigits(xs):
	return functools.reduce(lambda i, j: 10 * i + j, xs)

def solve(x):

	def _invert(k):
		return k if k < 5 else 9 - k
	digits = integerdigits(x)
	if digits[0] == 9:
		return fromdigits([9] + [_invert(d) for d in digits[1:]])
	else:
		return fromdigits(map(_invert, digits))

def main():
	x = int(input())
	result = solve(x)
	print(result)
main()


def chewbacca(nn):
	list1 = [int(i) for i in nn]
	list2 = [9 - i for i in list1]
	d = []
	for i in range(len(list1)):
		d.append(str(min(list1[i], list2[i])))
	x = ''.join(d)
	if x[0] == '0':
		x = '9' + x[1:]
	if x == '':
		return nn
	return x
n = input()
print(chewbacca(n))


import sys
x = input()
for i in range(len(x)):
	print(x[i] if i == 0 and x[i] == '9' else str(9 - int(x[i])) if int(x[i]) > 4 else x[i], end='')


x = input()
r = list(x)
for (i, c) in enumerate(x):
	c = int(c)
	if 9 - c < c and (i > 0 or 9 - c != 0):
		r[i] = 9 - c
print(''.join(map(str, r)))


st = str(input())
lst = []
for i in st:
	lst.append(int(i))
a = 0
if lst[0] == 9:
	a = 1
else:
	a = 0
for i in range(a, len(lst)):
	if lst[i] >= 5:
		lst[i] = 9 - lst[i]
lst = map(str, lst)
print(''.join(lst))


n = input()
for i in range(len(n)):
	if int(n[i]) >= 5:
		if i == 0 and int(n[i]) == 9:
			continue
		n = n[:i] + str(9 - int(n[i])) + n[i + 1:]
print(n)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def smp():
	return map(str, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def remadd(x, y):
	return 1 if x % y else 0

def ceil(a, b):
	return (a + b - 1) // b

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
s = inp()
b = ''
for i in range(len(s)):
	if i == 0 and s[i] == '9':
		b += '9'
	else:
		b += str(9 - int(s[i])) if int(s[i]) > 4 else s[i]
print(b)


n = input()
l = [str(min(int(x), 9 - int(x))) for x in n]
if l[0] == '0':
	l[0] = '9'
print(''.join(l))


def main():
	n = input()
	res = []
	for (i, c) in enumerate(n):
		if i == 0:
			c = str(9 - int(c)) if 9 > int(c) >= 5 else c
		if int(c) >= 5 and 0 < i < len(n):
			c = str(9 - int(c))
		res.append(c)
	res = ''.join(res).lstrip('0')
	print(res if len(res) else 0)
main()


I = input
x = list(map(int, I()))
if x[0] != 9 and 9 - x[0] < x[0]:
	x[0] = 9 - x[0]
for i in range(1, len(x)):
	if 9 - x[i] < x[i]:
		x[i] = 9 - x[i]
print(*x, sep='')


a = input()
a = list(a)
if a[0] != '9':
	for i in range(len(a)):
		if int(a[i]) >= 5:
			a[i] = 9 - int(a[i])
	a = ''.join((str(i) for i in a))
	print(a)
else:
	for i in range(1, len(a)):
		if int(a[i]) >= 5:
			a[i] = 9 - int(a[i])
	a = ''.join((str(i) for i in a))
	print(a)


x = list(input())
w = []
if x[0] == '9' or x[0] < '5':
	w.append(x[0])
else:
	w.append(9 - int(x[0]))
for i in range(1, len(x)):
	if x[i] < '5':
		w.append(x[i])
	else:
		w.append(9 - int(x[i]))
z = []
for i in w:
	z.append(int(i))
r = ''.join([str(elem) for elem in z])
print(r)


string = input()
a = list(string)
b = [int(x) for x in a]
if b[0] >= 5 and b[0] != 9:
	b[0] = 9 - b[0]
for i in range(1, len(b)):
	if b[i] >= 5:
		j = 9 - b[i]
		b[i] = j
s = ''.join((str(x) for x in b))
print(s)


s = list(map(int, list(input())))
s1 = ''
if s[0] == 9:
	s1 += str(s[0])
elif s[0] >= 0 and s[0] <= 4:
	s1 += str(s[0])
else:
	s1 += str(9 - s[0])
for i in range(1, len(s)):
	if s[i] >= 0 and s[i] <= 4:
		s1 += str(s[i])
	else:
		s1 += str(9 - s[i])
print(s1)


s = input()
flag = True
sx = ''
for i in s:
	if int(i) <= 4:
		sx += i
	else:
		x = 9 - int(i)
		if s.index(i) == 0 and x == 0 and (flag == True):
			sx += str(9)
			flag = False
		else:
			sx += str(x)
print(sx)


def solve():
	num = input()
	res = ''
	for i in range(len(num)):
		temp = int(num[i])
		if temp >= 5 and (not (9 - temp == 0 and i == 0)):
			res += str(9 - temp)
		else:
			res += str(num[i])
	print(res)
solve()


def main():
	x = int(input())
	y = str(x)
	list1 = []
	for char in y:
		list1.append(char)
	for i in range(len(list1)):
		if 9 - int(list1[i]) < int(list1[i]):
			list1[i] = 9 - int(list1[i])
	if list1[0] == 0:
		list1[0] = 9
	for i in range(len(list1)):
		print(list1[i], end='')
main()


number = str(input())
rev = ''
if 9 - int(number[0]) < int(number[0]) and 9 - int(number[0]) != 0:
	rev = str(9 - int(number[0]))
else:
	rev = number[0]
for i in range(1, len(number)):
	if 9 - int(number[i]) < int(number[i]):
		rev += str(9 - int(number[i]))
	else:
		rev += number[i]
print(rev)


def inv(a):
	return str(9 - int(a))

def alter(x, i):
	return x[:i] + inv(x[i]) + x[i + 1:]
x = input()
if x[0] != '9' and x[0] > inv(x[0]):
	x = alter(x, 0)
for i in range(1, len(x)):
	if x[i] > inv(x[i]):
		x = alter(x, i)
print(x)


n = input()
s = ''
a = 0
a = int(n[0])
if a >= 5 and a != 9:
	a = 9 - a
s += str(a)
for i in range(1, len(n)):
	a = int(n[i])
	if a >= 5:
		a = 9 - a
	s += str(a)
print(s)


s = input()
s1 = ''
if s[0] == '9' or ord(s[0]) < 53:
	s1 += s[0]
else:
	s1 += chr(ord('9') - ord(s[0]) + 48)
for i in range(1, len(s)):
	if ord(s[i]) >= 53:
		s1 += chr(ord('9') - ord(s[i]) + 48)
	else:
		s1 += s[i]
print(s1)


n = str(input())
v = []
for l in range(len(n)):
	if n[l] == '-':
		v.append('-' + n[1])
	elif n[0] == '-' and l == 1:
		pass
	else:
		v.append(n[l])
for i in range(len(v)):
	if int(v[i]) <= 4:
		v[i] = str(v[i])
	elif v[0] == '9' and i == 0:
		v[i] = '9'
	else:
		v[i] = str(9 - int(v[i]))
f = abs(int(''.join(v)))
print(f)


x = list(input())
for i in range(len(x)):
	if i == 0 and x[i] == '9':
		continue
	if int(x[i]) > 9 - int(x[i]):
		x[i] = str(9 - int(x[i]))
y = 0
for item in x:
	y *= 10
	y += int(item)
print(y)


n = input()
n = list(n)
for i in range(0, len(n)):
	if n[i] > '4':
		n[i] = chr(ord('9') - ord(n[i]) + ord('0'))
if n[0] == '0':
	n[0] = '9'
for i in range(0, len(n)):
	print(n[i], end='')


k = -1
for i in input():
	k += 1
	if i == '9' and (not k):
		print(i, end='')
	else:
		print(min(int(i), 9 - int(i)), end='')


S = input()
k = len(S)
for i in range(k):
	if 9 - int(S[i]) < int(S[i]):
		S = S[:i] + str(9 - int(S[i])) + S[i + 1:]
if S[0] == '0':
	S = '9' + S[1:]
print(S)


n = list(map(int, input()))
if n[0] > 4 and n[0] != 9:
	n[0] = 9 - n[0]
for i in range(1, len(n)):
	if n[i] > 4:
		n[i] = 9 - n[i]
print(*n, sep='')


t = input()
if int(t[0]) > 4 and int(t[0]) != 9:
	t = str(9 - int(t[0])) + t[1:]
for i in range(1, len(t)):
	if int(t[i]) > 4:
		if i != len(t) - 1:
			t = t[:i] + str(9 - int(t[i])) + t[i + 1:]
		else:
			t = t[:i] + str(9 - int(t[i]))
print(t)


numero = str(input())
final = ''
for k in range(1, len(numero)):
	test = int(numero[len(numero) - k])
	if test <= 4:
		final += numero[len(numero) - k]
	else:
		final += str(9 - test)
if 4 < int(numero[0]) and int(numero[0]) < 9:
	final += str(9 - int(numero[0]))
else:
	final += numero[0]
final = final[::-1]
print(final)


x = list(input())
if '4' < x[0] < '9':
	x[0] = str(9 - int(x[0]))
for i in range(1, len(x)):
	if x[i] > '4':
		x[i] = str(9 - int(x[i]))
print(''.join(x))


x = list(input())
for i in range(len(x)):
	if int(x[i]) > 9 - int(x[i]):
		x[i] = str(9 - int(x[i]))
if x[0] == '0':
	x[0] = '9'
if x == ['0']:
	print('9')
else:
	print(''.join(x))


s = list(map(int, input()))
if 4 < s[0] < 9:
	s[0] = 9 - s[0]
for i in range(1, len(s)):
	if s[i] > 4:
		s[i] = 9 - s[i]
print(*s, sep='')


str = input()
for (i, ch) in enumerate(str):
	ch = int(ch)
	if i == 0 and ch == 9:
		print(9, end='')
	else:
		print(min(ch, 9 - ch), end='')


x = input()
if x[0] == '9' or x[0] < '5':
	print(x[0], end='')
else:
	print(9 - int(x[0]), end='')
for c in x[1:]:
	if c < '5':
		print(c, end='')
	else:
		print(chr(ord('9') - ord(c) + ord('0')), end='')


n = str(input())
op = ''
if n[0] == '9':
	op += ''.join('9')
	k = 1
else:
	k = 0
for i in range(k, len(n)):
	if int(n[i]) > 4:
		j = 9 - int(n[i])
		op += ''.join(str(j))
	else:
		op += ''.join(n[i])
print(op)


num = input()
result = ''
for i in range(len(num)):
	ch = num[i]
	if not (i == 0 and ch == '9') and ord(ch) - ord('0') > ord('9') - ord(ch):
		result += str(ord('9') - ord(ch))
	else:
		result += ch
print(result)


__author__ = 'artyom'
ary = list(map(int, list(input())))
print(''.join([str(ary[0] if ary[0] < 5 or ary[0] == 9 else 9 - ary[0])] + [str(min(x, 9 - x)) for x in ary[1:]]))


x = int(input())
x = str(x)
l = []
if int(x[0]) == 9 or int(x[0]) < 5:
	l.append(int(x[0]))
else:
	l.append(9 - int(x[0]))
for i in range(1, len(x)):
	if int(x[i]) > 4:
		l.append(9 - int(x[i]))
	else:
		l.append(int(x[i]))
for i in l:
	print(i, end='')


x = list(input())
leadzero = True
for i in range(len(x)):
	s = int(x[i])
	if s > 9 - s:
		if not (s == 9 and leadzero):
			x[i] = str(9 - s)
	if int(x[i]) != 0:
		leadzero = False
print(''.join(x))


a = input()
d = a
s = ''
for i in range(len(d)):
	if i == 0:
		if a[i] == '9':
			s += '9'
			continue
	s += str(min(int(a[i]), 9 - int(a[i])))
print(int(s))


n = int(input())
a = []
while n:
	a.append(n % 10)
	n = n // 10
for i in range(len(a)):
	if 9 - a[i] < a[i] and a[i] != 9:
		a[i] = 9 - a[i]
	elif i != len(a) - 1 and 9 - a[i] < a[i]:
		a[i] = 9 - a[i]
r = 0
for i in range(len(a) - 1, -1, -1):
	r = r + a[i]
	r = r * 10
print(r // 10)


n = input()
x = list(str(int(n[0]) if int(n[0]) < 5 or int(n[0]) == 9 else 9 - int(n[0])))
u = [str(int(n[i]) if int(n[i]) < 5 else 9 - int(n[i])) for i in range(1, len(n))]
x.extend(u)
print(''.join(x))


x = input()
t = ''
if x[0] == '9':
	t = '9'
elif int(x[0]) >= 5:
	t = str(9 - int(x[0]))
else:
	t = x[0]
for i in range(1, len(x)):
	if int(x[i]) >= 5:
		t += str(9 - int(x[i]))
	else:
		t += x[i]
print(t)


import sys, itertools, math

def ia():
	return [int(i) for i in sys.stdin.readline().strip().split(' ')]

def ii():
	return int(sys.stdin.readline().strip())

def istr():
	return sys.stdin.readline().strip()
s = list(istr())
first = True
for i in range(len(s)):
	n = int(s[i])
	inv = 9 - n
	if first and inv == 0:
		s[i] = n
	else:
		s[i] = min(n, inv)
	first = False
ans = int(''.join([str(i) for i in s]))
print(ans)


s = str(input(''))
L = []
L.extend(s)
for i in range(len(L)):
	L[i] = int(L[i])
	if i != 0 or L[i] != 9:
		L[i] = min(L[i], 9 - L[i])
	else:
		L[i] = 9
for i in range(len(L)):
	L[i] = str(L[i])
print(''.join(L).lstrip('0'))


n = input()
result = []
for i in range(len(n)):
	number = int(n[i])
	if number < 5:
		result.append(str(number))
	elif i == 0 and number == 9:
		result.append(str(number))
	else:
		result.append(str(9 - number))
print(''.join(result))


num = int(input())
nums = [int(i) for i in str(num)]

def check(index):
	status = False
	for i in range(index):
		if nums[index] > 0:
			status = True
	return status
for (index, value) in enumerate(nums):
	if value > 4:
		if value < 9 or check(index):
			nums[index] = 9 - value
magic = lambda nums: int(''.join((str(i) for i in nums)))
print(magic(nums))


x = [9 - i if i >= 5 else i for i in map(int, input())]
print(9 - x[0] if x[0] == 0 else x[0], ''.join(map(str, x[1:])), sep='')


from sys import stdin, stdout, stderr, setrecursionlimit
setrecursionlimit(100000)

def debug(*e):
	if not __debug__:
		print(*e, file=stderr)

def dd(*vals):
	import inspect, re
	frame = inspect.getframeinfo(inspect.stack()[1][0])
	vs = re.search('dd\\((.+)\\)', frame.code_context[0]).group(1).split(',')
	if vs:
		debug(','.join(('{0} = {1}'.format(vs[i], v) for (i, v) in enumerate(vals))))

def trace(f):

	def traced(*args, **kw):
		debug('calling {} with args {}, {}'.format(f.__name__, args, kw))
		return f(*args, **kw)
	return traced

def read():
	return stdin.readline().rstrip()

def readarr(sep=None, maxsplit=-1):
	return read().split(sep, maxsplit)

def readint():
	return int(read())

def readia(sep=None, maxsplit=-1):
	return [int(a) for a in readarr(sep, maxsplit)]

def write(*args, **kwargs):
	sep = kwargs.get('sep', ' ')
	end = kwargs.get('end', '\n')
	stdout.write(sep.join((str(a) for a in args)) + end)

def writea(arr, sep=' ', end='\n'):
	stdout.write(sep.join((str(a) for a in arr)) + end)
n = [int(i) for i in read()]
r = []
for i in n:
	if i > 4 and (not (len(r) == 0 and i == 9)):
		r.append(9 - i)
	else:
		r.append(i)
writea(r, sep='')


a = list(input())
for i in range(len(a)):
	x = int(a[i])
	y = 9 - x
	if y < x:
		a[i] = str(y)
if a[0] == str(0):
	a[0] = str(9)
print(''.join(a))


string = input()
count = 0
for i in range(len(string)):
	if string[i] == '9':
		print('9', sep='', end='')
		count += 1
		break
	else:
		break
for j in range(count, len(string)):
	if string[j] == '5':
		print('4', sep='', end='')
	elif string[j] == '6':
		print('3', sep='', end='')
	elif string[j] == '7':
		print('2', sep='', end='')
	elif string[j] == '8':
		print('1', sep='', end='')
	elif string[j] == '9':
		print('0', sep='', end='')
	else:
		print(string[j], sep='', end='')


s = list(input())
for i in range(len(s)):
	if i == 0 and s[i] == '9':
		continue
	if int(s[i]) >= 5:
		s[i] = str(9 - int(s[i]))
print(*s, sep='')


n = list(map(int, list(input())))
for i in range(len(n)):
	n[i] = min(n[i], 9 - n[i])
if n[0] == 0:
	n[0] = 9
print(*n, sep='')


import math

def main():
	s = input()
	l = list()
	for i in range(0, len(s)):
		if i == 0 and 9 - int(s[i]) == 0:
			l.append(s[i])
		else:
			x = 9 - int(s[i])
			if x < int(s[i]):
				l.append(x)
			else:
				l.append(int(s[i]))
	for i in range(0, len(s)):
		print(l[i], end='')
main()


s = list(map(int, list(input())))
for x in range(len(s)):
	if s[x] >= 5:
		s[x] = 9 - s[x]
if s[0] == 0:
	s[0] = 9
print(''.join([str(elem) for elem in s]))


def solve(n):
	digit = 0
	new_n = []
	while n > 0:
		digit = n % 10
		new_n.append(str(min(digit, 9 - digit)))
		n //= 10
	new_n.reverse()
	if digit == 9:
		new_n[0] = '9'
	return ''.join(new_n)
n = int(input())
print(solve(n))


s = input()
a = []
for i in s:
	a.append(int(i))
for i in range(len(a)):
	if i == 0:
		if 9 - a[i] < a[i] != 9:
			a[i] = 9 - a[i]
	elif 9 - a[i] < a[i]:
		a[i] = 9 - a[i]
print(''.join((str(e) for e in a)))


n = input()
r = ''
if int(n[0]) == 9 or int(n[0]) <= 4:
	r += n[0]
else:
	r += str(9 - int(n[0]))
for i in range(1, len(n)):
	if int(n[i]) <= 4:
		r += n[i]
	else:
		r += str(9 - int(n[i]))
print(r)


n = list(input())
for i in range(len(n)):
	n[i] = int(n[i])
for i in range(len(n)):
	if i == 0 and n[i] == 9:
		pass
	elif n[i] <= 9 - n[i]:
		pass
	else:
		n[i] = 9 - n[i]
for i in n:
	print(i, end='')


n = input()
l = []
if n[0] == '9':
	l.append(str(9))
	for i in range(1, len(n)):
		x = int(n[i])
		if 9 - x < x:
			l.append(str(9 - x))
		else:
			l.append(str(x))
else:
	for i in n:
		x = int(i)
		if 9 - x < x:
			l.append(str(9 - x))
		else:
			l.append(str(x))
print(''.join(l))


a = int(input(''))
ans = []
for i in str(a):
	if int(i) > 4:
		ans.append(str(9 - int(i)))
	else:
		ans.append(i)
if ans[0] == '0':
	ans[0] = str(9)
ans = ''.join(ans)
print(int(ans))


s = input().strip()
ans = ''
for i in range(len(s)):
	if i == 0 and s[i] == '9':
		ans += '9'
		continue
	ans += str(min(int(s[i]), int(9 - int(s[i]))))
print(ans)


a = input()
for i in range(len(a)):
	if (i != 0 or int(a[i]) != 9) and int(a[i]) > 9 - int(a[i]):
		print(9 - int(a[i]), end='')
	else:
		print(a[i], end='')


number = input()
l = list(number)
for i in range(0, len(l)):
	if 9 - int(l[i]) < int(l[i]):
		if i == 0:
			if 9 - int(l[i]) != 0:
				l[i] = 9 - int(l[i])
		else:
			l[i] = 9 - int(l[i])
for i in l:
	print(i, end='')


x = input()
a = 0
if x[0] is '9':
	a = 1
	print(9, end='')
for i in x[a:]:
	if i >= '5':
		print(9 - int(i), end='')
	else:
		print(i, end='')


d = {'9': '0', '8': '1', '7': '2', '6': '3', '5': '4', '4': '4', '3': '3', '2': '2', '1': '1', '0': '0'}
x = input()
ans = ''
non_zero = True
for c in x:
	if c == '9' and non_zero:
		ans += '9'
		non_zero = False
	else:
		ans += d[c]
		non_zero = False
print(ans)


x = input()
l = list(x)
n = len(x)
if int(x[0]) > 4 and int(x[0]) < 9:
	l[0] = 9 - int(x[0])
for i in range(n - 1):
	if int(x[i + 1]) > 4:
		l[i + 1] = 9 - int(x[i + 1])
ans = ''
for i in range(n):
	ans += str(l[i])
print(ans)


a = input()
b = ''
i = 0
if a[i] == '9':
	b += a[i]
	i += 1
while i < len(a):
	b += str(min(int(a[i]), 9 - int(a[i])))
	i += 1
print(b)


import math, os, sys
import string, re
import itertools, functools, operator
from collections import Counter

def inputint():
	return int(input())

def inputarray(func=int):
	return map(func, input().split())
s = list(map(lambda x: str(x) if x < 5 else str(9 - x), map(int, list(input()))))
print(''.join(s) if s[0] != '0' else '9' + ''.join(s[1:]))


n = [int(i) for i in input()]
s = ''
for i in range(len(n)):
	if n[i] > 4:
		if i == 0 and n[i] == 9:
			continue
		n[i] = 9 - n[i]
s = ''.join((str(i) for i in n))
print(s)


s = input()
n = len(s)
if s[0] == '9':
	s1 = '9'
	for i in range(1, n):
		r = int(s[i])
		if r >= 5 and r <= 9:
			s1 = s1 + str(9 - r)
		else:
			s1 = s1 + str(r)
	print(s1)
else:
	s1 = ' '
	for i in range(0, n):
		r = int(s[i])
		if r >= 5 and r <= 9:
			s1 = s1 + str(9 - r)
		else:
			s1 = s1 + str(r)
	print(s1[1:])


n = list(map(int, list(input())))
list2 = []
i = 0
for j in n:
	if i == 0 and 9 - j < j and (9 - j != 0):
		list2.append(9 - j)
	elif 9 - j < j and i != 0:
		list2.append(9 - j)
	else:
		list2.append(j)
	i += 1
print(''.join(map(str, list2)))


n = input()
start = 0
if n[0] == '9':
	start += 1
	print(n[0], end='')
for i in n[start:]:
	z = ''
	if i < str(ord('9') - ord(i)):
		z = i
	else:
		z = str(ord('9') - ord(i))
	print(z, end='')
print()


numm = input()
for i in range(len(numm)):
	if i == 0 and numm[i] == '9':
		print(numm[i], end='')
	elif int(numm[i]) < 5:
		print(numm[i], end='')
	else:
		print(9 - int(numm[i]), end='')


T = input()
list_arg = list(T)
if not int(list_arg[0]) == 9:
	if int(list_arg[0]) >= 5:
		list_arg[0] = str(9 - int(list_arg[0]))
for i in range(1, len(list_arg)):
	if int(list_arg[i]) >= 5:
		list_arg[i] = str(9 - int(list_arg[i]))
print(int(''.join(list_arg)))


n = input()
for i in range(len(n)):
	if int(n[i]) < 5 or (i == 0 and n[i] == '9'):
		print(n[i], end='')
	else:
		print(9 - int(n[i]), end='')


n = input()
flag = 0
for i in range(len(n)):
	if n[i] and int(n[i]) < 9 or i > 0:
		flag = 1
	if int(n[i]) > 4:
		if flag:
			print(9 - int(n[i]), end='')
		else:
			print(n[i], end='')
	else:
		print(n[i], end='')


n = list(input())
for (index, digit) in enumerate(n):
	d = int(digit)
	if 9 - d < d:
		if index != 0 or 9 - d != 0:
			n[index] = str(9 - d)
print(''.join(n))


line = input()
op = ''
if line[0] == '9':
	op += '9'
else:
	op += str(min(int(line[0]), 9 - int(line[0])))
for i in line[1:]:
	op += str(min(int(i), 9 - int(i)))
print(op)


x = input()
x2 = ''
for i in range(len(x)):
	t = x[i]
	if int(x[i]) >= 5:
		t = 9 - int(x[i])
	x2 = x2 + str(t)
if x2[0] == '0':
	x2 = x2.replace('0', '9', 1)
print(int(x2))


x = int(input())
l = list(map(int, str(x)))
m = len(l)
for i in range(m):
	if l[0] == 9 and i == 0:
		continue
	else:
		l[i] = min(l[i], 9 - l[i])
s = [str(i) for i in l]
p = int(''.join(s))
print(p)


s = list(input())
l = [int(x) for x in s]
for i in range(len(l)):
	if l[i] > 4:
		if not (i == 0 and l[i] == 9):
			l[i] = 9 - l[i]
print(*l, sep='')


x = list(map(int, list(input())))
for i in range(len(x)):
	if i != 0 or x[i] != 9:
		x[i] = min(x[i], 9 - x[i])
print(''.join(map(str, x)))


s = input()
out = ''
for i in range(len(s)):
	digit = int(s[i])
	if digit == 9 and i == 0:
		digit = s[i]
	elif digit > 4:
		digit = 9 - digit
		digit = str(digit)
	else:
		digit = s[i]
	out += digit
print(out)


n = input()
i = 0
if i < len(n) and n[i] == '9':
	print('9', end='')
	i += 1
for j in range(i, len(n)):
	if ord(n[j]) > ord('4'):
		print(9 - int(n[j]), end='')
	else:
		print(n[j], end='')


n = input()
a = []
for i in range(len(n)):
	a.append(int(n[i]))
if a[0] != 9:
	for i in range(len(a)):
		if a[i] > 4:
			a[i] = 9 - a[i]
else:
	for i in range(1, len(a)):
		if a[i] > 4:
			a[i] = 9 - a[i]
for i in range(len(a)):
	print(a[i], end='')
print()


import sys
t = 1
for ___ in range(t):
	n = int(input())
	ans = []
	while n:
		x = n % 10
		if x > 9 - x:
			ans.append(9 - x)
		else:
			ans.append(x)
		st = x
		n = n // 10
	if ans[-1] == 0:
		ans[-1] = st
	print(*ans[::-1], sep='')


s = list(map(lambda x: min(x, 9 - x), map(int, input())))
if s[0] == 0:
	s[0] = 9
print(''.join(map(str, s)))


Number = input()
count = 1
for Digit in Number:
	if count == 1 and int(Digit) == 9:
		print(Digit, end='')
		count = 2
	elif int(Digit) >= 5:
		Digit = 9 - int(Digit)
		print(Digit, end='')
		count = 2
	else:
		print(Digit, end='')
		count = 2


text = input()
start = 0
answer = ''
if text[0] == '9':
	start += 1
	answer += text[0]
for i in range(start, len(text)):
	if text[i] >= '5':
		answer += str(9 - int(text[i]))
	else:
		answer += text[i]
print(answer)


l = list(input())
ans = ''
if l[0] == '9':
	ans += '9'
else:
	ans += str(min(int(l[0]), 9 - int(l[0])))
for i in range(1, len(l)):
	ans += str(min(int(l[i]), 9 - int(l[i])))
print(ans)


word = input()
for i in range(len(word)):
	if i == 0:
		if word[i] == '9':
			print(9, end='')
		elif word[i] == '8':
			print(1, end='')
		elif word[i] == '7':
			print(2, end='')
		elif word[i] == '6':
			print(3, end='')
		elif word[i] == '5':
			print(4, end='')
		else:
			print(word[i], end='')
	elif word[i] == '9':
		print(0, end='')
	elif word[i] == '8':
		print(1, end='')
	elif word[i] == '7':
		print(2, end='')
	elif word[i] == '6':
		print(3, end='')
	elif word[i] == '5':
		print(4, end='')
	else:
		print(word[i], end='')


n = str(input())
l = list(map(int, n))
for i in range(len(n)):
	if i == 0:
		if l[0] == 9:
			continue
		if l[i] > abs(9 - l[i]):
			l[i] = abs(9 - l[i])
	if l[i] > abs(9 - l[i]):
		l[i] = abs(9 - l[i])
for i in range(len(n)):
	print(l[i], end='')


n = input().strip()
k = ''
for i in range(len(n)):
	if i == 0 and n[i] == '9':
		k += '9'
	elif int(n[i]) > 4:
		k += str(9 - int(n[i]))
	else:
		k += n[i]
print(int(k))


t = ''
for ch in input():
	t += ch if ch < '5' else str(9 - int(ch))
print('9' + t[1:] if t[0] == '0' else t)


num = str(input())
for i in range(len(num)):
	if int(num[i]) >= 5 and int(num[i]) != 9:
		print(9 - int(num[i]), end='')
	elif int(num[i]) == 9 and i != 0:
		print(9 - int(num[i]), end='')
	else:
		print(int(num[i]), end='')
print()


n = input()
s = n[0] if n[0] < '5' or n[0] == '9' else str(9 - int(n[0]))
for i in range(1, len(n)):
	s += n[i] if n[i] < '5' else str(9 - int(n[i]))
print(s)


n = list(input())
for i in range(len(n)):
	a = int(n[i])
	if i == 0:
		if a > 4 and a != 9:
			n[i] = str(9 - a)
		else:
			continue
	elif a > 4:
		n[i] = str(9 - a)
	else:
		continue
m = ''.join(n)
print(m)


str1 = ''
c = 0
for k in input():
	if c == 0 and 5 <= int(k) < 9:
		str1 += str(9 - int(k))
	elif 5 <= int(k) <= 9 and c != 0:
		str1 += str(9 - int(k))
	else:
		str1 += k
	c += 1
print(str1)


x = list(map(int, input()))
if len(x) == 1:
	x = x[0]
	if x <= 4:
		print(x)
	elif x <= 8:
		print(9 - x)
	elif x == 9:
		print(9)
	exit()
if 5 <= x[0] <= 8:
	x[0] = 9 - x[0]
for i in range(1, len(x)):
	if x[i] >= 5:
		x[i] = 9 - x[i]
print(''.join(map(str, x)))


a = input()
a = [int(x) for x in a]
ar = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
if 5 <= ar[a[0]] <= 8:
	a[0] = 9 - a[0]
for x in range(1, len(a)):
	if 5 <= ar[a[x]] <= 9:
		a[x] = 9 - a[x]
q = int(''.join(map(str, a)))
print(q)


def main():
	s = list(input().strip())
	x = int(s[0])
	if x > 9 - x:
		if x != 9:
			print(9 - x, end='')
		else:
			print(x, end='')
	else:
		print(x, end='')
	for i in range(1, len(s)):
		x = int(s[i])
		if x > 9 - x:
			x = 9 - x
		print(x, end='')

def fun(m, n, s, k):
	return

def fun2(s):
	return
from sys import *
import inspect
import re
from math import *
import threading
from collections import *
from pprint import pprint as pp
mod = 998244353
MAX = 10 ** 5

def lie():
	return int(input())

def liee():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def deb(p):
	for line in inspect.getframeinfo(inspect.currentframe().f_back)[3]:
		m = re.search('\\bdeb\\s*\\(\\s*([A-Za-z_][A-Za-z0-9_]*)\\s*\\)', line)
		print('%s %d' % (m.group(1), p))

def vector(size, val=0):
	vec = [val for i in range(size)]
	return vec

def matrix(rowNum, colNum, val=0):
	mat = []
	for i in range(rowNum):
		collumn = [val for j in range(colNum)]
		mat.append(collumn)
	return mat

def dmain():
	setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
dmain()


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
n = z()
ans = ''
c = 0
for i in n:
	x = int(i)
	if x >= 5:
		if x == 9 and c == 0:
			ans += str(i)
			c = 1
			continue
		ans += str(9 - x)
		c = 1
	else:
		ans += i
		c = 1
print(ans)


s = input()
s1 = ''
for i in range(len(s)):
	x = int(s[i])
	if i != 0:
		if x <= 9 - x:
			s1 += str(x)
		else:
			s1 += str(9 - x)
	elif 9 - x == 0:
		s1 += str(x)
	elif x <= 9 - x:
		s1 += str(x)
	else:
		s1 += str(9 - x)
print(int(s1))


a = list(map(int, input()))
for i in range(len(a)):
	if a[i] > 4:
		if i == 0 and a[i] == 9:
			pass
		else:
			a[i] = 9 - a[i]
a = list(map(str, a))
print(''.join(a))


x = input()
for i in ['5', '6', '7', '8', '9']:
	if i in x:
		x = x.replace(i, str(9 - int(i)))
if x[0] == '0':
	x = x.replace('0', '9', 1)
print(x)


x = list(map(int, list(input())))
for (i, el) in enumerate(x):
	if el > 4 and (not (i == 0 and el == 9)):
		x[i] = 9 - el
print(''.join(map(str, x)))


def change_char(s, p, r):
	return s[:p] + r + s[p + 1:]
s = str(input())
for i in range(len(s)):
	if i == 0 and s[i] == '9':
		continue
	elif int(s[i]) > 4:
		s = change_char(s, i, str(9 - int(s[i])))
print(s)


X = input()
ans = []
for x in X:
	xx = int(x)
	ans.append(min(xx, 9 - xx))
if ans[0] == 0:
	ans[0] = 9
ans = ''.join(map(str, ans))
print(ans)


n = input()
new = ''
l = len(n)
if n[0] != '9':
	if int(n[0]) > 9 - int(n[0]):
		new += str(9 - int(n[0]))
	else:
		new += n[0]
else:
	new += n[0]
for i in range(1, l):
	if int(n[i]) > 9 - int(n[i]):
		new += str(9 - int(n[i]))
	else:
		new += n[i]
print(new)


l = list(map(int, input()))
s = ''
for i in range(len(l)):
	if i == 0 and l[i] == 9:
		s += str(l[i])
		continue
	if l[i] > 4:
		l[i] = 9 - l[i]
	s += str(l[i])
print(s)


k = input()
a = []
for i in k:
	a.append(int(i))
for i in range(len(a)):
	if a[i] > 4:
		if i != 0 and a[0] != 9:
			a[i] = abs(a[i] - 9)
		elif i == 0 and a[0] == 9:
			a[i] = a[i]
		else:
			a[i] = abs(a[i] - 9)
for i in a:
	print(i, end='')


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n').split(' ')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
x = str(val())
s = ''
for i in range(len(x)):
	if i and 9 - int(x[i]) < int(x[i]):
		s += str(9 - int(x[i]))
	elif not i and 9 - int(x[i]) and (9 - int(x[i]) < int(x[i])):
		s += str(9 - int(x[i]))
	else:
		s += x[i]
print(s)


n = input()
mn = 0
t = []
for i in n:
	mn = min(9 - int(i), int(i))
	t.append(mn)
if t[0] != 0:
	for i in range(len(n)):
		print(t[i], end='')
else:
	t[0] = 9
	for i in range(len(n)):
		print(t[i], end='')


a = input('')
outstring = ''
check1 = True
if a[0] == '9':
	outstring = outstring + '9'
	check1 = False
for value in range(len(a)):
	if value == 0 and check1 == True:
		if int(a[value]) < 5:
			outstring = outstring + a[value]
		else:
			outstring = outstring + str(9 - int(a[value]))
	if value != 0:
		if int(a[value]) < 5:
			outstring = outstring + a[value]
		else:
			outstring = outstring + str(9 - int(a[value]))
print(outstring)


x = input()
pre = x
hack = x
p = set()
for san in range(len(x)):
	p.add(x[san])
string = str(p)
if string == "{'9'}":
	print(9, end='')
	for j in range(len(x) - 1):
		print(0, end='')
	quit()
for i in range(len(x)):
	x = x.replace(x[i], str(9 - int(x[i])))
	if int(x) < int(pre) and int(x) != 0:
		pre = min(pre, x)
	else:
		x = pre
if x[0] == '0':
	print(hack[0] + x[1:])
else:
	print(x)


y = input()
b = list(y)
p = 0
for c in b:
	p += 1
	i = int(c)
	x = min(i, 9 - i)
	if i == 9 and p == 1:
		print(9, end='')
	else:
		print(x, end='')


n = str(input())
ans = [str(x) if int(x) < 9 - int(x) else str(9 - int(x)) for x in n]
if ans[0] == '0':
	ans[0] = '9'
print(''.join(ans))


s = [min(int(i), 9 - int(i)) for i in input()]
if s[0] == 0:
	s[0] = 9
print(*s, sep='')


n = input()
x = [str(int(n[i]) if int(n[i]) < 5 else 9 - int(n[i])) for i in range(len(n))]
if x[0] == '0':
	x[0] = '9'
print(''.join(x))


a = [min(int(j), 9 - int(j)) for j in input()]
if a[0] == 0:
	a[0] = 9
print(*a, sep='')


s = input()
r = ''
for i in range(len(s)):
	x = int(s[i])
	if i == 0 and x == 9:
		r = r + s[0]
	elif x < 9 - x:
		r = r + str(x)
	else:
		r = r + str(9 - x)
print(r)


n = input()
result = ''
for i in range(len(n)):
	if n[i] == '9' and i == 0:
		result += n[i]
	elif 9 - int(n[i]) < int(n[i]):
		result += str(9 - int(n[i]))
	else:
		result += n[i]
print(result)


number = input()
result = []
for i in range(len(number)):
	d = int(number[i])
	digit = d if d < 5 or (d == 9 and i == 0) else 9 - d
	result.append(digit)
print(''.join(map(str, result)))


x = list(input())
minx = []
for i in range(0, len(x)):
	minx.append('9' if i == 0 and x[0] == '9' else min(x[i], str(9 - int(x[i]))))
print(''.join(minx))


n = input()
str = ''
numb = ord(n[0]) - ord('0')
if numb > 9 - numb and 9 - numb != 0:
	str = str + chr(9 - numb + ord('0'))
else:
	str = str + n[0]
for i in range(1, len(n)):
	numb = ord(n[i]) - ord('0')
	if numb > 9 - numb:
		str = str + chr(9 - numb + ord('0'))
	else:
		str = str + n[i]
print(str)


n = input()
i = 0
while i < len(n):
	if i == 0 and n[i] == '9':
		print(9, end='')
	elif int(n[i]) > 4:
		print(9 - int(n[i]), end='')
	else:
		print(int(n[i]), end='')
	i += 1


x = input()
x = x.replace('', ' ').strip().split()
for c in range(len(x)):
	if int(x[c]) > 4:
		x[c] = str(9 - int(x[c]))
if int(x[0]) == 0:
	x[0] = str(9)
x = ''.join(x)
print(x)


input = input()
str_variable = ''
count = 0
for x in str(input):
	x = int(x)
	if count == 0 and x == 9:
		x = 9
	elif x > 4:
		x = 9 - int(x)
	str_variable += str(x)
	count += 1
int_variable = int(str_variable)
if int_variable == 0:
	int_variable = 9
print(int_variable)


num = input()
if num[0] == '9':
	for i in range(1, len(num)):
		if int(num[i]) > 9 - int(num[i]):
			num = num.replace(num[i], str(9 - int(num[i])))
	print('9' + num[1:len(num)])
else:
	for i in range(0, len(num)):
		if int(num[i]) > 9 - int(num[i]):
			num = num.replace(num[i], str(9 - int(num[i])))
	print(num)


n = int(input())
string = ''
g = n
while n > 9:
	check = n % 10
	if check > 4:
		check = 9 - check
	string = str(check) + string
	n = n // 10
if n == 9:
	string = str(n) + string
	print(string)
elif n > 4:
	print(str(9 - n) + string)
else:
	print(str(n) + string)


def read_number_line():
	return [int(i) for i in input().split()]
result = ''
for digit in input():
	digit = int(digit)
	if digit >= 5:
		digit = 9 - digit
	if result == '' and digit == 0:
		result += '9'
	else:
		result += str(digit)
print(result)


g = input()
ns = []
for i in range(len(g)):
	if i == 0:
		if int(g[i]) == 9:
			ns.append(str(g[i]))
		elif int(g[i]) >= 5:
			ns.append(str(9 - int(g[i])))
		else:
			ns.append(str(g[i]))
	elif int(g[i]) >= 5:
		ns.append(str(9 - int(g[i])))
	else:
		ns.append(str(g[i]))
print(''.join(ns))


x = input()
ans = ''
was = False
for c in x:
	c = int(c)
	if not was and c == 9:
		pass
	elif c >= 5:
		c = 9 - c
	ans += str(c)
	was = True
print(ans)


def invert(x):
	x = list(map(int, str(x)))
	for (i, t) in enumerate(x):
		if 9 - t < t:
			if i == 0:
				x[i] = 9 - t if t != 9 else t
			else:
				x[i] = 9 - t
	return ''.join(map(str, x))
x = int(input())
x_inv = invert(x)
print(x_inv)


from sys import stdin, stdout
from collections import Counter

def ai():
	return list(map(int, stdin.readline().split()))

def ei():
	return map(int, stdin.readline().split())

def ip():
	return int(stdin.readline().strip())

def op(ans):
	return stdout.write(str(ans) + '\n')
n = [int(i) for i in str(ip())]
for i in range(len(n)):
	if n[i] > 4:
		if n[i] == 9 and i == 0:
			continue
		else:
			n[i] = 9 - n[i]
print(''.join([str(i) for i in n]))


a = str(input())
b = str()
for i in range(len(a)):
	if int(a[i]) >= 5:
		if int(a[i]) == 9 and i == 0:
			b = b + '9'
		else:
			b = b + str(9 - int(a[i]))
	else:
		b = b + a[i]
print(b)


numbers = list(str(input()))
final = ''
for (idx, number) in enumerate(numbers):
	if idx == 0 and number == '9':
		final += number
	elif int(number) >= 5:
		final += str(9 - int(number))
	else:
		final += number
print(final)


a = input()
c = ''
for i in range(len(a)):
	n = int(a[i])
	if 9 - n == 0 and i == 0:
		c += a[i]
	elif 9 - n < n:
		c += str(9 - n)
	else:
		c += a[i]
print(c)


import sys
f = sys.stdin
s = f.readline().strip()
p = ''
start = 0
for u in s:
	m = int(u)
	if m > 4 and start > 0 or (m > 4 and m < 9 and (start == 0)):
		m = 9 - m
	if start > 0:
		p = p + str(m)
	elif m > 0:
		p = p + str(m)
	start += 1
print(p)


x = input()
x = list(x)
y = ''
if x[0] == '9':
	y += x[0]
	del x[0]
for i in range(len(x)):
	if 9 - int(x[i]) > int(x[i]):
		y += x[i]
	else:
		y += str(9 - int(x[i]))
print(y)


n = input()
l = len(n)
n = int(n)
s = []
while n > 0:
	t1 = n % 10
	if t1 == 9 and n < 10:
		t2 = 9
	else:
		t2 = 9 - t1
	s.append(str(min(t1, t2)))
	n //= 10
print(''.join(s[::-1]))


n = input()
i = 0
l = len(n)
num = 0
if n[i] == '9':
	num = 9
	i += 1
z = ord('0')
while i < l:
	if 9 - (ord(n[i]) - z) < 5:
		num = num * 10 + 9 - (ord(n[i]) - z)
	else:
		num = num * 10 + (ord(n[i]) - z)
	i += 1
print(num)


num = list(map(int, str(input())))
for i in range(len(num)):
	if i == 0 and num[i] == 9:
		continue
	elif num[i] > 4:
		num[i] = 9 - num[i]
print(int(''.join((str(j) for j in num))))


n = input()
lis = list(map(int, n))
for i in range(len(lis)):
	if lis[i] > 9 - lis[i]:
		lis[i] = 9 - lis[i]
if lis[0] == 0:
	lis[0] = 9
lis1 = list(map(str, lis))
res = int(''.join(lis1))
print(res)


data = input()
answer = 0
length = len(data)
for i in range(length):
	digit = int(data[length - i - 1])
	answer += min(digit, 9 - digit) * pow(10, i)
if answer == 0:
	print(9 * pow(10, len(data) - 1))
elif data[0] == '9':
	print(9 * pow(10, len(data) - 1) + answer)
else:
	print(answer)


a = input()
if len(a) == 1:
	a = int(a)
	print([a, 9 - a][a >= 5 and a < 9])
else:
	x = int(a[0])
	print([x, 9 - x][x >= 5 and x < 9], end='')
	for i in a[1:]:
		i = int(i)
		print([i, 9 - i][i >= 5 and i <= 9], end='')


s = input()
ans = 0
for c in s:
	if ans == 0 and int(c) == 9:
		ans = ans * 10 + 9
	elif int(c) > 4:
		ans = ans * 10 + (9 - int(c))
	else:
		ans = ans * 10 + int(c)
if ans == 0:
	print(s)
else:
	print(ans)


def main():
	s = read(0)
	t = ''
	for i in range(len(s)):
		t += str(min(int(s[i]), 9 - int(s[i])))
	if t[0] == '0':
		t = '9' + t[1:]
	print(t)

def read(mode=2):
	inputs = input().strip()
	if mode == 0:
		return inputs
	if mode == 1:
		return inputs.split()
	if mode == 2:
		return list(map(int, inputs.split()))

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s, end='')
write(main())


import sys
number = sys.stdin.readline()
lista = []
for i in range(0, len(number) - 1):
	num = int(number[i])
	invert_num = 9 - num
	if num < invert_num:
		lista.append(num)
	else:
		lista.append(invert_num)
if lista[0] == 0:
	lista[0] = 9
for i in lista:
	print(i, end='')
print()


s = str(input())
if s[0] != '9':
	for i in range(0, len(s)):
		if s[i] == '5' or s[i] == '6' or s[i] == '7' or (s[i] == '8') or (s[i] == '9'):
			s = s.replace(s[i], str(9 - int(s[i])))
	print(int(s))
elif len(s) == 1:
	print('9')
else:
	for i in range(1, len(s)):
		if s[i] == '5' or s[i] == '6' or s[i] == '7' or (s[i] == '8') or (s[i] == '9'):
			s = s.replace(s[i], str(9 - int(s[i])))
	print('9' + s[1:])


def main():
	l = list(map(int, input()))
	for (i, x) in enumerate(l):
		if x > 4:
			l[i] = 9 - x
	if not l[0]:
		l[0] = 9
	print(''.join(map(str, l)))
main()


x = [int(i) for i in input()]
for i in range(len(x)):
	if x[i] == 9 and len(x) == 1:
		pass
	elif i == 0 and x[i] == 9:
		pass
	else:
		x[i] = min(x[i], abs(9 - x[i]))
x = list(map(str, x))
print(int(''.join(x)))


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)

def binary(l, r, ll, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		if ll[mid] >= val:
			ans = ll[mid]
			return binary(l, mid - 1, ll, val, ans)
		else:
			return binary(mid + 1, r, ll, val, ans)
n = str(input())
i1 = 0
s2 = ''
if n[i1:i1 + 1] == '9':
	s2 = s2 + '9'
	i1 += 1
for i in range(i1, len(n)):
	if 9 - int(n[i:i + 1]) <= int(n[i:i + 1]):
		s2 = s2 + str(9 - int(n[i:i + 1]))
	else:
		s2 = s2 + n[i:i + 1]
print(s2)


new = ''
a = int(input())
a = str(a)
t = len(a)
for i in range(t):
	if i == 0:
		if int(a[i]) <= 4 or int(a[i]) == 9:
			new += str(a[i])
		else:
			new += str(9 - int(a[i]))
	elif int(a[i]) <= 4:
		new += str(a[i])
	else:
		new += str(9 - int(a[i]))
print(new)


s = list(input())
for i in range(len(s)):
	if i == 0 and 5 <= int(s[i]) <= 8 or (i != 0 and 5 <= int(s[i]) <= 9):
		s[i] = str(9 - int(s[i]))
	print(s[i], end='')


k = list(input())
s = ''
leading = True
for d in k:
	i = int(d)
	if leading and i == 9:
		s += d
	else:
		s += str(min([i, 9 - i]))
	leading = False
print(s)


s = str(input())
for i in range(len(s)):
	dis = 9 - int(ord(s[i]) - ord('0'))
	if dis < ord(s[i]) - ord('0'):
		s = s[:i] + chr(dis + ord('0')) + s[i + 1:]
if s[0] == '0':
	s = '9' + s[1:]
print(s)


s = input()
k = 0
for i in range(len(s) - 1):
	m = int(s[len(s) - i - 1])
	k += min(9 - m, m) * 10 ** i
m = int(s[0])
if 9 - m == 0:
	m = int(s[0])
else:
	m = min(9 - m, int(s[0]))
k += m * 10 ** (len(s) - 1)
print(k)


def toInt(s):
	return int(''.join(s))

def main():
	digits = list(input())
	if digits[0] != '9':
		digits[0] = str(min(int(digits[0]), 9 - int(digits[0])))
	for i in range(1, len(digits)):
		digits[i] = str(min(int(digits[i]), 9 - int(digits[i])))
	print(toInt(digits))
main()


num = input()
fnl = ''
if num[0] == '9':
	fnl += '9'
elif int(num[0]) < 5:
	fnl += num[0]
else:
	fnl += str(9 - int(num[0]))
for each in num[1:]:
	if int(each) < 5:
		fnl += each
	else:
		fnl += str(9 - int(each))
print(fnl)


n = [min(int(i), 9 - int(i)) for i in input()]
if n[0] < 1:
	n[0] = 9
print(*n, sep='')


str_num = input()
new_num = ''
for (i, dig) in enumerate(str_num):
	if 9 - int(dig) < int(dig) and (not (i == 0 and 9 - int(dig) == 0)):
		new_num += str(9 - int(dig))
	else:
		new_num += dig
if int(new_num) <= 0:
	print(str_num)
else:
	print(new_num)


a = input()
print(*[9 - int(a[i]) if int(a[i]) > 4 and (i != 0 or a[i] != '9') else int(a[i]) for i in range(len(a))], sep='')


a = input()
ans = ''
for i in range(len(a)):
	if i == 0:
		if 9 - int(a[i]) > 0:
			if 9 - int(a[i]) < int(a[i]):
				ans += str(9 - int(a[i]))
			else:
				ans += a[i]
		else:
			ans += a[i]
	elif 9 - int(a[i]) < int(a[i]):
		ans += str(9 - int(a[i]))
	else:
		ans += a[i]
print(ans)


n = int(input())
a = []
while n > 0:
	a.append(n % 10)
	n = n // 10
a.reverse()
for i in range(1, len(a)):
	if a[i] > 4:
		a[i] = 9 - a[i]
if a[0] != 9 and a[0] > 4:
	a[0] = 9 - a[0]
m = 0
for i in range(len(a)):
	m = m * 10 + a[i]
print(m)


s = input()
list = []
if s[0] == '9':
	list.append(s[0])
else:
	a = int(s[0])
	if 9 - a < a:
		a = 9 - a
	list.append(str(a))
for a in s[1:]:
	a = int(a)
	if 9 - a < a:
		a = 9 - a
	list.append(str(a))
res = ''.join(list)
print(res)


def chew(s):
	answer = ''
	for x in s:
		if int(x) > 9 - int(x):
			if answer == '':
				if 9 - int(x) != 0:
					answer += str(9 - int(x))
				else:
					answer += x
			else:
				answer += str(9 - int(x))
		else:
			answer += x
	return answer
s = input()
print(chew(s))


x = input()
for i in range(len(x)):
	y = int(x[i])
	if y == 9 and i == 0:
		print(y, end='')
	elif y > 4 and y <= 9:
		print(9 - y, end='')
	else:
		print(y, end='')


s = input()
ans = ''
if s[0] == '9':
	ans += '9'
elif int(s[0]) >= 5:
	ans += str(9 - int(s[0]))
else:
	ans += s[0]
for i in range(1, len(s)):
	if int(s[i]) >= 5:
		ans += str(9 - int(s[i]))
	else:
		ans += s[i]
print(ans)


x = input()
ans = ''
for (i, e) in enumerate(x):
	if i == 0 and e == '9':
		ans += '9'
		continue
	ans += str(min(int(e), 9 - int(e)))
if ans == '0':
	print(x)
else:
	print(ans)


a = list(map(int, input()))
if 4 < a[0] < 9:
	a[0] = 9 - a[0]
for i in range(1, len(a)):
	if a[i] > 4:
		a[i] = 9 - a[i]
for x in a:
	print(x, end='')
print()


ans = ''
for i in input():
	if 9 - int(i) < int(i) and (not (ans == '' and i == '9')):
		ans += str(9 - int(i))
	else:
		ans += i
print(ans)


l = list(map(int, str(int(input()))))
n = len(l)
for i in range(n):
	l[n - i - 1] = min(9 - l[n - i - 1], l[n - i - 1])
if l[0] == 0:
	l[0] = 9
print(*l, sep='')


n = int(input())
original = []
ans = []
while n > 0:
	original += [n % 10]
	n = n // 10
original.reverse()
for digit in original:
	ans += [min(digit, 9 - digit)]
if ans[0] == 0:
	ans[0] = 9
print(''.join(map(str, ans)))


x = input()
z = int(x)
x = list(x)
for i in range(len(x)):
	t = x[i]
	x[i] = str(9 - int(x[i]))
	if int(x[0]) > 0 and int(''.join(x)) < z:
		z = int(''.join(x))
	else:
		x[i] = t
print(''.join(x))


def getMinNumb(number):
	listNumber = list(map(int, list(str(number))))
	for (i, v) in enumerate(listNumber):
		if v > 4:
			if v != 9 or i > 0:
				listNumber[i] = 9 - v
	return int(''.join(map(str, listNumber)))
a = int(input())
print(getMinNumb(a))


import sys
a = input()
b = list(a)
for i in range(0, len(b)):
	if i == 0 and b[i] == '9':
		continue
	if b[i] > '4':
		b[i] = chr(ord('9') - (ord(b[i]) - ord('0')))
if b[len(b) - 1] == '9' and len(b) > 1:
	b[len(b) - 1] = '0'
print(''.join(b))


a = int(input())
b = []
for i in str(a):
	b.append(int(i))
string = ''
for i in b:
	if i > 4:
		string += str(9 - i)
	else:
		string += str(i)
if string[0] == '0':
	print('9' + string[1:])
else:
	print(string)


try:
	n = input()
	l = []
	if ord(n[0]) > 52 and ord(n[0]) != 57:
		l.append(57 - ord(n[0]) + 48)
	else:
		l.append(ord(n[0]))
	for i in range(1, len(n)):
		if ord(n[i]) > 52:
			l.append(57 - ord(n[i]) + 48)
		else:
			l.append(ord(n[i]))
	for i in l:
		print(chr(i), end='')
except:
	pass


word = input()
ans = ''
count = 0
for num in word:
	if count == 0 and 9 - int(num) > 0 and (9 - int(num) < int(num)):
		ans += str(9 - int(num))
	elif count != 0 and 9 - int(num) < int(num):
		ans += str(9 - int(num))
	else:
		ans += num
	count += 1
print(int(ans))


num = input()
ans = ''
for (i, c) in enumerate(num):
	n = int(c)
	if i == 0:
		ans += str(9 - n if n > 4 and n != 9 else n)
	else:
		ans += str(9 - n if n > 4 else n)
print(int(ans))


a = list(map(int, list(input())))
n = len(a)
for i in range(n):
	if a[i] >= 5:
		a[i] = 9 - a[i]
if a[0] == 0:
	a[0] = 9
print(''.join([str(i) for i in a]))


def transform_digit(digit):
	if int(digit) > 4:
		return str(9 - int(digit))
	return digit
number = input()
transformed_digits = []
for digit in number:
	transformed_digits.append(transform_digit(digit))
if transformed_digits[0] == '0':
	transformed_digits[0] = '9'
print(''.join(transformed_digits))


import sys
a = [int(x) for x in input()]
if len(a) == 1 and a[0] == 9:
	print('9')
	sys.exit()
if a[0] > 4 and a[0] != 9:
	a[0] = 9 - a[0]
for i in range(1, len(a)):
	if a[i] > 4:
		a[i] = 9 - a[i]
for i in range(len(a)):
	a[i] = str(a[i])
a = ''.join(a)
a = int(a)
print(a)


number = input()
ans = ''
if number[0] == '9':
	ans = '9'
	for i in range(1, len(number)):
		if int(number[i]) > 4:
			ans += str(9 - int(number[i]))
		else:
			ans += number[i]
else:
	for i in range(len(number)):
		if int(number[i]) > 4:
			ans += str(9 - int(number[i]))
		else:
			ans += number[i]
print(ans)


n = list(map(int, list(input())))
if n[0] < 5 or n[0] == 9:
	n[0] = str(n[0])
else:
	n[0] = str(9 - n[0])
for i in range(1, len(n)):
	if n[i] < 5:
		n[i] = str(n[i])
	else:
		n[i] = str(9 - n[i])
print(''.join(n))


inp = input().split()
arr = [int(x) for x in inp[0]]
ans = ''
for i in arr:
	if (len(ans) != 0 or i != 9) and i > 9 - i:
		ans += str(9 - i)
	else:
		ans += str(i)
print(ans)


def solve(n):
	for i in range(len(n)):
		if int(n[i]) >= 5 and i > 0:
			n[i] = str(9 - int(n[i]))
		if i == 0 and int(n[i]) >= 5 and (n[i] != '9'):
			n[i] = str(9 - int(n[i]))
	return ''.join(n)
n = list(input())
print(solve(n))


s = input()
u = ''
for i in range(len(s)):
	t = int(s[i])
	if i == 0 and t == 9:
		u = u + str(t)
	elif t > 4:
		t = 9 - t
		u = u + str(t)
	else:
		u = u + str(t)
print(u)


numero = input()
for i in range(0, len(numero)):
	if int(numero[i]) > 9 - int(numero[i]) and (i != 0 or numero[i] != '9'):
		numero = numero[:i] + str(9 - int(numero[i])) + numero[i + 1:]
print(numero)


ch = str(input())
r = ''
A = '0123456789'
for i in range(len(ch)):
	if int(ch[i]) >= 5:
		r += A[9 - A.index(ch[i])]
	else:
		r += ch[i]
if r[0] == '0':
	r = '9' + r[1:]
print(r)


res = ''
non_zero = False
for n in map(int, input()):
	if 9 - n < n:
		if 9 - n == 0:
			if non_zero:
				res += str(9 - n)
			else:
				res += str(n)
				non_zero = True
		else:
			res += str(9 - n)
			non_zero = True
	else:
		res += str(n)
		non_zero = True
print(res)


l = list(input())
l = list(map(int, l))
a = 0
if l[0] == 9:
	a = 1
for i in range(a, len(l)):
	if l[i] >= 5:
		l[i] = 9 - l[i]
print(*l, sep='')


n = input()
list1 = list(n)
if list1[0] == '9':
	j = 1
else:
	j = 0
for i in range(j, len(list1)):
	num = int(list1[i])
	if 9 - num < num:
		list1[i] = str(9 - num)
a = ''.join(list1)
print(a)


n = int(input())
s = str(n)
list1 = list(s)
if int(list1[0]) >= 5 and int(list1[0]) < 9:
	z = int(list1[0])
	z = 9 - z
	list1[0] = str(z)
for i in range(1, len(list1)):
	if int(list1[i]) >= 5:
		z = int(list1[i])
		z = 9 - z
		list1[i] = str(z)
ss = ''
for i in range(len(list1)):
	ss += list1[i]
ss = int(ss)
print(ss)


x = input()
invert = {'0': '0', '1': '1', '2': '2', '3': '3', '4': '4', '5': '4', '6': '3', '7': '2', '8': '1', '9': '0'}
if x[0] == '9':
	ans = '9'
else:
	ans = invert[x[0]]
for i in x[1:]:
	ans += invert[i]
print(ans)


def tt(m):
	t = 0
	while m != 0:
		m = m // 10
		t = t + 1
	return t

def ma(m):
	n = 0
	while m != 0:
		n = n * 10 + m % 10
		m = m // 10
	return n
n = int(input())
m = 0
a = n
while n != 0:
	y = n % 10
	n = n // 10
	if y >= 5:
		y = 9 - y
	if n == 0 and y == 0:
		y = 9
	m = m * 10 + y
h = tt(a) - tt(ma(m))
if h != 0:
	print(ma(m) * 10 ** h)
else:
	print(ma(m))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from heapq import *
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 10 ** 9 + 7

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve(case):
	n = list(inp())
	for i in range(len(n)):
		n[i] = int(n[i])
	for i in range(len(n)):
		if i == 0:
			if n[i] != 9:
				n[i] = min(n[i], 9 - n[i])
			continue
		n[i] = min(n[i], 9 - n[i])
	print(''.join((str(n[i]) for i in range(len(n)))))
testcase(1)


n = input()
for x in range(5, 10):
	n = n.replace(str(x), str(9 - x))
if n[0] == '0':
	print('9' + n[1:])
else:
	print(n)


a = list(input())
b = ''
for i in range(len(a)):
	a[i] = int(a[i])
for i in range(len(a)):
	if a[i] > 4:
		if i == 0 and a[0] == 9:
			a[0] = a[0]
		else:
			a[i] = abs(a[i] - 9)
for i in range(len(a)):
	b += str(a[i])
print(b)


def get_value():
	num = input()
	result = ''
	for (ind, char) in enumerate(num):
		char = int(char)
		if ind == 0 and 9 - char == 0:
			result += str(char)
			continue
		if 9 - char < char:
			result += str(9 - char)
		else:
			result += str(char)
	return result
print(get_value())


m = input()
m = list(m)
m = [int(u) for u in m]
res = []
for i in range(len(m)):
	if i == 0 and m[i] == 9:
		res.append(9)
	elif m[i] >= 5:
		res.append(9 - m[i])
	else:
		res.append(m[i])
m = [str(u) for u in res]
print(''.join(m))


num = input()
out = []
for i in range(len(num)):
	if i == 0 and num[i] == '9':
		out.append(str(9))
	elif int(num[i]) > 4:
		out.append(str(9 - int(num[i])))
	else:
		out.append(num[i])
print(''.join(out))


X = [int(i) for i in str(input())]
X[0] = 9 - X[0] if X[0] >= 5 and X[0] < 9 else X[0]
for i in range(1, len(X)):
	if X[i] >= 5:
		X[i] = 9 - X[i]
print(*X, sep='')


snum = input()
num = [int(x) for x in snum]
for i in range(1, len(num)):
	if num[i] > 4:
		num[i] = 9 - num[i]
if num[0] != 9 and num[0] > 4:
	num[0] = 9 - num[0]
print(''.join((str(x) for x in num)))


number = map(int, list(input()))
result = []
for (index, n) in enumerate(number):
	if index == 0 and n == 9:
		result.append(n)
	else:
		result.append(min(n, 9 - n))
print(''.join(map(str, result)))


def invert(n):
	return str(min(9 - int(n), int(n)))
n = input().strip()
for i in range(len(n)):
	if i == 0 and n[i] == '9':
		print('9', end='')
		continue
	print(invert(n[i]), end='')


n = int(input())
num = list(str(n))
flag = 0
if len(num) == 1:
	if num[0] == '9':
		flag = 1
		print(9)
if flag == 0:
	if num[0] == '9':
		x = 1
	else:
		x = 0
	for i in range(x, len(num)):
		if int(num[i]) >= 5:
			num[i] = str(9 - int(num[i]))
	print(''.join(num))


x = input()
x = list(str(x))
for i in range(len(x)):
	temp = int(x[i])
	if i == 0:
		if temp == 9:
			continue
		elif 9 - temp < temp:
			x[i] = 9 - temp
	elif 9 - temp < temp:
		x[i] = 9 - temp
s = ''.join((str(i) for i in x))
print(s)


n = input()
a = ''
for i in range(len(n)):
	if int(n[i]) < 5 or (i == 0 and n[i] == '9'):
		a += n[i]
	else:
		a += str(9 - int(n[i]))
print(a)


X = input()
A = ''
first = True
for ch in X:
	if ch == '9' and first:
		A += ch
	else:
		v = ord(ch) - ord('0')
		if v > 4:
			v = 9 - v
		A += chr(v + ord('0'))
	first = False
print(A)


d = {'9': '0', '8': '1', '7': '2', '6': '3', '5': '4'}
s = input()
ans = ''
for i in range(len(s)):
	if i == 0 and s[i] == '9':
		print('9', end='')
	elif s[i] in d:
		print(d[s[i]], end='')
	else:
		print(s[i], end='')


x = input()
ans = ''
l = 0
if x[0] == '9':
	ans += '9'
	l = 1
for f in range(l, len(x)):
	if int(x[f]) < 9 - int(x[f]):
		ans += x[f]
	else:
		ans += str(9 - int(x[f]))
print(ans)


def changeDigit(t):
	return str(ord('9') - ord(t))
x = list(input())
for i in range(len(x)):
	if i == 0:
		if x[i] == '9':
			continue
	y = changeDigit(x[i])
	if int(x[i]) > int(y):
		x[i] = y
print(''.join(x))


s = input().rstrip()
result = ''
if s[0] == '9':
	result += '9'
	s = s[1:]
for i in s:
	if 9 - int(i) < int(i):
		result += str(9 - int(i))
	else:
		result += i
print(result)


s = input()
l = list(s)
for i in range(0, len(l)):
	if 9 - int(l[i]) < int(l[i]):
		if 9 - int(l[i]) == 0 and i == 0:
			pass
		else:
			l[i] = str(9 - int(l[i]))
	print(l[i], end='')


c = input().replace('5', '4').replace('6', '3').replace('7', '2').replace('8', '1').replace('9', '0')
if c[0] == '0':
	c = '9' + c[1:]
print(c)


r = []
for i in [int(i) for i in input()]:
	if not r and i == 9:
		r.append(i)
	else:
		r.append(min(i, 9 - i))
print(''.join((str(i) for i in r)))


num = list(input())
ans = ''
for i in num:
	if int(i) >= 5:
		ans += str(9 - int(i))
	else:
		ans += str(i)
if '0' in ans[0]:
	ans = ans.replace('0', '9', 1)
print(int(ans))


def solve(digits):
	inverted = ''
	for i in digits:
		if int(i) >= 5:
			inverted += str(9 - int(i))
		else:
			inverted += i
	digits = ''
	if inverted[0] == '0':
		digits += '9'
	else:
		digits += inverted[0]
	for i in range(1, len(inverted)):
		digits += inverted[i]
	return digits
n = input()
print(solve(n))


n = list(input())
for i in range(len(n)):
	if i == 0 and n[i] == '9':
		continue
	if 9 - int(n[i]) < int(n[i]):
		n[i] = str(9 - int(n[i]))
print(''.join(n))


def ans(x):
	s = str(x)
	arr = []
	for i in range(len(s)):
		if i is 0:
			if 9 - int(s[0]) < int(s[0]) and 9 - int(s[0]) > 0:
				arr.append(str(9 - int(s[0])))
			else:
				arr.append(s[0])
			pass
		else:
			if 9 - int(s[i]) < int(s[i]):
				arr.append(str(9 - int(s[i])))
			else:
				arr.append(s[i])
			pass
	return int(''.join(arr))
	pass
x = int(input())
print(ans(x))


from sys import exit
s = input()
s = list(s)
m = min(s)
x = 0
if len(s) == 1:
	if int(s[0]) >= 5 and int(s[0]) < 9:
		print(9 - int(s[0]))
		exit(0)
	else:
		print(''.join(s))
		exit(0)
if int(s[0]) == 9:
	x = 1
for i in range(len(s)):
	if x == 1:
		x += 1
	elif int(s[i]) >= int(m) and int(s[i]) >= 5:
		s[i] = str(9 - int(s[i]))
print(''.join(s))


s = input()
n = len(s)
ans = ''
if s[0] != '9' and s[0] >= '5':
	ans += str(9 - int(s[0]))
else:
	ans = s[0]
for i in range(1, n):
	if s[i] > '4':
		ans += str(9 - int(s[i]))
	else:
		ans += s[i]
print(ans)


inStr = input()
nOfRadix = len(inStr)
n = int(inStr)

def invertDigit(n, nOfRadix, i):
	s = str(n)
	if i == 0 and s[i] == '9':
		return n
	si = s[i]
	digit = int(si)
	if digit <= 4:
		return n
	else:
		inverse = 9 - digit
	return int(s[:i] + str(inverse) + s[i + 1:])
min = n
for i in range(nOfRadix):
	cur = invertDigit(n, nOfRadix, i)
	if cur < min:
		min = cur
		n = min
print(min)


n = input()
n1 = ''
if int(n[0]) != 9:
	n1 += str(min(int(n[0]), 9 - int(n[0])))
else:
	n1 += '9'
for i in n[1:]:
	n1 += str(min(int(i), 9 - int(i)))
print(n1)


num = list(input(''))
dic = {'0': '0', '1': '1', '2': '2', '3': '3', '4': '4', '5': '4', '6': '3', '7': '2', '8': '1', '9': '0'}
if num[0] != '9':
	num[0] = dic[num[0]]
for i in range(1, len(num)):
	num[0] = num[0] + dic[num[i]]
print(num[0])


a = int(input())
b = []
while a > 0:
	b.append(a % 10)
	a = a // 10
for i in range(len(b)):
	if i == len(b) - 1 and b[i] == 9:
		b[i] = 9
	else:
		b[i] = min(b[i], 9 - b[i])
b.reverse()
for i in b:
	print(i, end='')


s = list(input())
for i in range(0, len(s)):
	if i == 0:
		if s[i] == '9':
			pass
		else:
			s[i] = str(min(int(s[i]), 9 - int(s[i])))
	else:
		s[i] = str(min(int(s[i]), 9 - int(s[i])))
print(*s, sep='')


s = [int(x) for x in input()]
d = []
if s[0] == 9:
	s[0] = 9
elif s[0] > 4:
	s[0] = 9 - s[0]
else:
	n = s[0]
print(s[0], end='')
for i in range(1, s.__len__()):
	if s[i] > 4:
		n = 9 - s[i]
	else:
		n = s[i]
	print(n, end='')


invert = {'5': '4', '6': '3', '7': '2', '8': '1', '9': '0'}
res = [invert.get(x, x) for x in input()]
if res[0] == '0':
	res[0] = '9'
print(''.join(res))


s = ''.join(map(str, (min(d, 9 - d) for d in map(int, input()))))
print('9' if s[0] == '0' else s[0], s[1:], sep='')


s = input()
res = ''
if int(s[0]) >= 5 and int(s[0]) != 9:
	res += str(9 - int(s[0]))
else:
	res += s[0]
for i in range(1, len(s)):
	if int(s[i]) >= 5:
		res += str(9 - int(s[i]))
	else:
		res += s[i]
print(res)


s = input()
i = 0
while i < len(s):
	if int(s[i]) > 4:
		s = s[:i] + str(9 - int(s[i])) + s[i + 1:]
	i += 1
if s[0] == '0':
	s = '9' + s[1:]
print(s)


x = int(input())
t = 1
s = 0
while x > 0:
	if x % 10 > 4 and x != 9:
		s = s + (9 - x % 10) * t
	else:
		s = s + x % 10 * t
	t = t * 10
	x = x // 10
print(s)


a = list(input())
for x in range(len(a)):
	if a[x] == '9' and x == 0:
		continue
	if int(a[x]) > 4:
		a[x] = str(9 - int(a[x]))
print(''.join(a))


starting_number = input()
skip = 0
for i in starting_number:
	if int(i) == 9:
		skip = skip + 1
		print('9', end='')
		break
	else:
		break
for i in starting_number[skip:]:
	if int(i) > 4:
		invert = 9 - int(i)
		print(invert, end='')
	else:
		print(i, end='')


n = input()
ans = ''
for i in n:
	if int(i) >= 5:
		ans += str(9 - int(i))
	else:
		ans += i
print(ans if ans[0] != '0' else '9' + ans[1:])


s = input()
n = len(s)
(cnt, i) = (0, 0)
ans = ''
if s[0] == '9':
	ans += '9'
	i += 1
for j in range(i, n):
	ans += str(min(int(s[j]), 9 - int(s[j])))
print(ans)


import math

def fact(n):
	ans = 1
	for i in range(2, n + 1):
		ans *= i
	return ans

def comb(n, c):
	return fact(n) // (fact(n - c) * c)
s = list(str(input()))
for i in range(len(s)):
	if s[i] == '9' and i == 0:
		continue
	if int(s[i]) > 4:
		s[i] = str(9 - int(s[i]))
print(''.join(s))


x = list(map(int, input()))
s = 0
for elem in range(len(x)):
	if x[elem] == 9 and (not s):
		s = 1
		continue
	if x[elem] > 4:
		x[elem] = 9 - x[elem]
	s = 1
print(*x, sep='')


def A(n):
	c = ''
	print(c.join(n))
z = input()
a = list(z)
for i in range(len(a)):
	if i == 0:
		if a == 9:
			print(9)
		elif 9 > int(a[0]) >= 5:
			a[0] = str(9 - int(a[0]))
	elif int(a[i]) >= 5:
		a[i] = str(9 - int(a[i]))
		a.insert(i + 1, a[i])
		a.pop(i)
A(a)


n = int(input())
s = 0
i = 1

def func(n):
	global s, i
	if n != 0:
		func(n // 10)
		p = n % 10
		if p >= 5:
			if p == 9 and i == 1:
				s = s * 10 + p
				i += 1
			else:
				s = s * 10 + 9 - p
				i += 1
		else:
			s = s * 10 + p
			i += 1
func(n)
print(s)


s = input()
for i in range(len(s)):
	if int(s[i]) > 9 - int(s[i]):
		s = s[:i] + str(9 - int(s[i])) + s[i + 1:]
if s[0] == '0':
	s = '9' + s[1:]
print(s)


s = input()
i = 0
for c in s:
	x = int(c)
	if x > 4:
		if i == 0 and x == 9:
			print(c, end='')
		else:
			print(9 - x, end='')
	else:
		print(c, end='')
	i += 1
print()


s = input().strip()
print(str(min(int(s[0]), 9 - int(s[0])) if int(s[0]) < 9 else s[0]) + ''.join([str(min(int(s[i]), 9 - int(s[i]))) for i in range(1, len(s))]))


a = list(map(int, input()))
k = 0
for i in a:
	if i >= 5:
		a[k] = 9 - i
	k += 1
if a[0] == 0:
	a[0] = 9
result = ''.join((str(n) for n in a))
print(result)


num = int(input())
ans = ''
while num > 9:
	dig = num % 10
	if dig > 4:
		dig = 9 - dig
	ans = str(dig) + ans
	num = num // 10
if num == 9:
	print(9, end='')
elif num > 4:
	print(9 - num, end='')
else:
	print(num, end='')
print(ans)


n = input()
s = ''
for i in n:
	s = s + str(min(int(i), 9 - int(i)))
if s[0] == '0':
	s = s.replace('0', '9', 1)
print(s)


n = input()
s = ''
j = 0
for i in n:
	if s == '' and i == '9':
		s += '9'
	elif int(i) > 4:
		s += str(9 - int(i))
	else:
		s += i
if int(s) == 0:
	s = '9'
print(int(s))


list_ = list(map(lambda x: x if x < '5' else str(9 - int(x)), input()))
if list_[0] == '0':
	list_[0] = '9'
print(''.join(list_))


x = input()
output = ''
if int(x[0]) >= 5:
	if int(x[0]) != 9:
		output += str(9 - int(x[0]))
	else:
		output += x[0]
else:
	output += x[0]
for i in range(1, len(x)):
	if int(x[i]) >= 5:
		output += str(9 - int(x[i]))
	else:
		output += x[i]
print(output)


l = list(map(int, input()))
k = len(l)
for i in range(0, k):
	a = 9 - l[i]
	if l[i] == 9 and i == 0:
		t = 1
	elif l[i] > a:
		l[i] = a
l = map(str, l)
l = ''.join(l)
print(int(l))


x = list(map(int, list(input())))
n = len(x)
if 9 - x[0] > 0 and 9 - x[0] < x[0]:
	x[0] = 9 - x[0]
for i in range(1, n):
	num = 9 - x[i]
	if num < x[i] and num >= 0:
		x[i] = num
x = list(map(str, x))
print(''.join(x))


x = list(input())
for i in range(len(x)):
	if x[i] >= '5':
		x[i] = str(9 - int(x[i]))
if x[0] == '0':
	x[0] = '9'
for i in range(len(x)):
	print(x[i], end='')


s = input()
ans = ''
for (i, x) in enumerate(s):
	if int(x) >= 5 and (not (i == 0 and x == '9')):
		ans += str(9 - int(x))
	else:
		ans += x
print(ans)


n = input()
m = ''
for i in range(1, len(n)):
	if n[i] >= '5':
		m += str(9 - int(n[i]))
	else:
		m += n[i]
else:
	if '9' > n[0] >= '5':
		m = str(9 - int(n[0])) + m
	elif n[0] == '9':
		m = '9' + m
	else:
		m = n[0] + m
print(m)


from sys import stdin
import collections

def bar(s):
	ans = ''
	f = False
	for ss in s.rstrip('\n'):
		if int(ss) >= 5:
			if int(ss) == 9 and (not f):
				ans += ss
				f = True
			else:
				ans += str(9 - int(ss))
				f = True
		else:
			ans += ss
			f = True
	return ans
s = stdin.readline()
print(bar(s))


import math
import os
import operator
s = input()
if s[0] == '9':
	print('9', end='')
else:
	t = 9 - int(s[0])
	if t <= int(s[0]):
		print(t, end='')
	else:
		print(s[0], end='')
for i in range(1, len(s)):
	t = 9 - int(s[i])
	if t <= int(s[i]):
		print(t, end='')
	else:
		print(s[i], end='')


n = input()
x = 0
for i in range(len(n)):
	if int(n[i]) > 4:
		x = 9 - int(n[i])
		if (x == 0) & (i == 0):
			print(9, end='')
		else:
			print(x, end='')
	else:
		print(n[i], end='')


def inversor(string, index):
	nova_string = ''
	for char in range(len(string)):
		if char != index:
			nova_string += string[char]
		else:
			nova_string += str(9 - int(string[char]))
	return nova_string
x = str(input())
for char in range(0, len(x)):
	atual = inversor(x, char)
	if int(x) > int(atual) and atual[0] != '0':
		x = atual
print(x)


x = str(input())
y = str()
for i in range(len(x)):
	if x[i] == '5':
		y += '4'
	elif x[i] == '6':
		y += '3'
	elif x[i] == '7':
		y += '2'
	elif x[i] == '8':
		y += '1'
	elif x[i] == '9' and i > 0:
		y += '0'
	else:
		y += x[i]
print(y)


import sys
import math
import bisect

def solve(s):
	n = len(s)
	A = []
	for i in range(n):
		val = ord(s[i]) - ord('0')
		if val == 9:
			if i == 0:
				A.append(val)
			else:
				A.append(0)
		else:
			A.append(min(val, 9 - val))
	return ''.join(list((str(a) for a in A)))

def main():
	ans = solve(input())
	print(ans)
main()


s = input()
ans = '0'
b = False
y = len(s)
for i in range(y):
	x = s[i]
	if int(x) >= 5 and (not (i == 0 and s[i] == '9')):
		x = str(9 - int(x))
	ans += x
print(ans[1:])


numbers = [int(c) for c in input()]
ans = ''
for (k, n) in enumerate(numbers):
	if k == 0 and n == 9:
		ans += '9'
	else:
		ans += str(9 - n) if n >= 5 else str(n)
print(ans)


n = str(input())
ans = ''
val = 9 - int(n[0])
if val == 0 or val >= int(n[0]):
	ans += n[0]
else:
	ans += str(val)
for i in range(1, len(n)):
	val = 9 - int(n[i])
	if val < int(n[i]):
		ans += str(val)
	else:
		ans += n[i]
print(ans)


s = str(input())
l = list(s)
p = ''
if int(l[0]) > 9 - int(l[0]):
	if int(l[0]) == 9:
		l[0] = str(9)
	else:
		l[0] = str(9 - int(l[0]))
for i in range(1, len(l)):
	if int(l[i]) > 9 - int(l[i]):
		l[i] = str(9 - int(l[i]))
for i in l:
	p = p + i
print(p)


s = list(input())
st = 0
ans = ''.join((str(x) for x in s[:st]))
for i in range(st, len(s)):
	if int(s[i]) > 4:
		ans += str(9 - int(s[i]))
	else:
		ans += s[i]
if ans[0] == '0':
	print('9' + ans[1:])
else:
	print(int(ans))


s = input()
if int(s[0]) == 9 or int(s[0]) < 5:
	print(s[0], end='')
else:
	print(9 - int(s[0]), end='')
for i in range(1, len(s)):
	if int(s[i]) < 5:
		print(s[i], end='')
	else:
		print(9 - int(s[i]), end='')
print()


n = input()
x = ''
if n[0] != '9':
	tmp = int(n[0])
	x += str(tmp if tmp < 9 - tmp else 9 - tmp)
else:
	x = '9'
for i in range(1, len(n)):
	tmp = int(n[i])
	x += str(tmp if tmp < 9 - tmp else 9 - tmp)
print(x)


number = str(input())
res = ''
flag = True
for digit in number:
	if flag and digit == '9':
		flag = False
		res += '9'
		continue
	if int(digit) <= 4:
		res += str(digit)
	else:
		res += str(9 - int(digit))
	if flag:
		flag = False
print(res)


s = list(input())
for (i, j) in zip(s, range(len(s))):
	s[j] = chr(min(ord(i) - ord('0'), 9 - (ord(i) - ord('0'))) + ord('0'))
if s[0] == '0':
	s[0] = '9'
print(*s, sep='')


n = input()
l = list(n)
for i in range(len(l)):
	if l[i] == '5':
		l[i] = '4'
	elif l[i] == '6':
		l[i] = '3'
	elif l[i] == '7':
		l[i] = '2'
	elif l[i] == '8':
		l[i] = '1'
	elif l[i] == '9':
		if i != 0:
			l[i] = '0'
print(''.join(map(str, l)))


a = 0
x = [int(z) for z in input()]
for c in range(len(x)):
	if x[c] == 9 and a == 0:
		print(x[c], end='')
		a += 1
		continue
	elif x[c] >= 5:
		x[c] = 9 - x[c]
		print(x[c], end='')
	else:
		print(x[c], end='')
	a += 1


a = list(input())
if a[0] != '9':
	a[0] = str(min(int(a[0]), 9 - int(a[0])))
for i in range(1, len(a)):
	a[i] = str(min(int(a[i]), 9 - int(a[i])))
print(''.join(a))


n = input()
m = len(n)
for i in range(m):
	a = int(n[i])
	if a == 5 or a == 6 or a == 7 or (a == 8) or (a == 9):
		n = n.replace(n[i], str(9 - a))
if n[0] == '0':
	n = '9' + n[1:]
print(n)


import math
from decimal import Decimal

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)
s = input()
new = ''
k = 0
for i in s:
	if int(i) > 4:
		if i == '9':
			if k != 0:
				new += str(9 - int(i))
			else:
				new += '9'
		else:
			new += str(9 - int(i))
	else:
		new += i
	k += 1
print(new)


from sys import stdin

def get_ints():
	return list(map(int, stdin.readline().strip().split()))
k = input()
a = ''.join((x if int(x) < 5 else str(int(9 - int(x))) for x in k))
if a[0] == '0':
	a = k[0] + a[1:]
if int(a) == 0:
	a = a[:-1] + k[-1]
print(a)


from sys import stdin, stdout
h = map(str, stdin.readline().rstrip().split())
h = [int(i) for i in h]
h = str(h)
v = list(h)
v = v[1:-1]
v = [int(i) for i in v]
for i in range(len(v)):
	if i == 0:
		if 9 - v[i] < v[i] and 9 - v[i] > 0:
			v[i] = 9 - v[i]
	elif 9 - v[i] < v[i]:
		v[i] = 9 - v[i]
v2 = ''.join([str(i) for i in v])
print(v2)


n = input()
r = ''
if n[0] == '9':
	r = '9'
	for i in range(1, len(n)):
		x = int(n[i])
		if x < 5:
			r = r + str(x)
		else:
			r = r + str(9 - x)
else:
	for i in range(len(n)):
		x = int(n[i])
		if x < 5:
			r = r + str(x)
		else:
			r = r + str(9 - x)
print(r)


import math
import datetime
from sys import stdin
x = input()
news = ''
count = 0
for token in x:
	k = int(token)
	if 9 - k < k:
		if 9 - k == 0:
			if count != 0:
				news += str(9 - k)
			else:
				news += token
		else:
			news += str(9 - k)
	else:
		news += token
	count += 1
print(news)


(s, strt) = (input(), 0)
l = [int(ele) for ele in s]
if l[0] == 9:
	strt = 1
for i in range(strt, len(l)):
	if l[i] > 4:
		l[i] = 9 - l[i]
s = ''
for e in l:
	s += str(e)
print(s)


mylist = list(map(int, input()))
if mylist[0] == 9:
	for i in range(1, len(mylist)):
		if 9 - mylist[i] < mylist[i]:
			mylist[i] = 9 - mylist[i]
else:
	for i in range(0, len(mylist)):
		if 9 - mylist[i] < mylist[i]:
			mylist[i] = 9 - mylist[i]
print(''.join((str(x) for x in mylist)))


x = input()
xnew = ''
n = len(x)
if x[0] == '9':
	xnew = xnew + x[0]
else:
	xnew = xnew + str(min(int(x[0]), 9 - int(x[0])))
for i in range(1, n):
	xnew = xnew + str(min(int(x[i]), 9 - int(x[i])))
print(xnew)


n = input()
a = ''
for i in n:
	if int(i) >= 5:
		if int(i) == 9 and a == '':
			a += '9'
		else:
			a += str(9 - int(i))
	else:
		a += i
print(a)


a = str(input())
x = ''
for i in range(len(a)):
	if int(a[i]) == 0 and i == 0:
		x += str(9 - int(a[i]))
		continue
	if int(a[i]) == 9 and i == 0:
		x += a[i]
		continue
	if int(a[i]) > 9 - int(a[i]):
		x += str(9 - int(a[i]))
		continue
	x += a[i]
print(x)


ans = [min(int(i), 9 - int(i)) for i in input()]
ans[0] = 9 if ans[0] == 0 else ans[0]
print(''.join((str(x) for x in ans)))


integer = input()
first_digit = integer[0]
integer = integer[1:]
for digit in integer:
	if int(digit) > 4:
		integer = integer.replace(digit, str(9 - int(digit)))
if int(first_digit) != 9 and int(first_digit) > 4:
	integer = str(9 - int(first_digit)) + integer
else:
	integer = first_digit + integer
print(integer)


x = input()
ans = []
if str(x)[0] == '9':
	ans.append(9)
	aux = [min(9 - int(t), int(t)) for t in x[1:]]
	ans += aux
else:
	aux = [min(9 - int(t), int(t)) for t in x]
	ans += aux
print(''.join(list(map(str, ans))))


a = input()
mat = []
for i in a:
	mat.append(int(i))
for i in range(len(mat)):
	if i == 0:
		if mat[i] != 9:
			if 9 - mat[i] < mat[i]:
				mat[i] = int(9 - mat[i])
	elif 9 - mat[i] < mat[i]:
		mat[i] = int(9 - mat[i])
for i in mat:
	print(i, end='')


x = input()
ans = []
start = 0
if x[0] == '9':
	ans.append('9')
	start = 1
for i in x[start:]:
	if i in ['5', '6', '7', '8', '9']:
		ans.append(str(9 - int(i)))
	else:
		ans.append(i)
print(''.join(ans))


def solve(s):
	s1 = ''
	for c in s:
		i = int(c)
		if i > 4:
			s1 += str(9 - i)
		else:
			s1 += c
	l = list(s1)
	if l[0] == '0':
		l[0] = '9'
	n = int(''.join(l))
	if n == 0:
		n = 9
	return n
s = input()
print(solve(s))


s = input()
l = []
n = len(s)
e = min(int(s[0]), 9 - int(s[0]))
if e == 0:
	print(s[0], end='')
else:
	print(e, end='')
for i in range(1, n):
	print(min(int(s[i]), 9 - int(s[i])), end='')


x = []
for (i, char) in enumerate(input()):
	if i > 0:
		if int(char) > 4:
			x.append(str(9 - int(char)))
		else:
			x.append(char)
	elif 4 < int(char) < 9:
		x.append(str(9 - int(char)))
	else:
		x.append(char)
print(int(''.join(x)))


v = [min(int(x), 9 - int(x)) for x in input()]
if v[0] < 1:
	v[0] = 9
print(''.join(map(str, v)))


num = input()
n = int(num)
(i, k) = (0, len(num))
while i < k:
	v = 9 - (ord(num[i]) - 48)
	if i == 0 and v == 0:
		i += 1
		continue
	if int(num[:i] + str(v) + num[i + 1:]) < n:
		n = int(num[:i] + str(v) + num[i + 1:])
		num = num[:i] + str(v) + num[i + 1:]
	i += 1
print(n)


digits = [*map(int, [*input().strip()])]
min_digits = [min(d, 9 - d) for d in digits]
s = ''.join((str(d) for d in min_digits))
if s[0] == '0':
	s = '9' + s[1:]
print(s)


n = int(input())
rev_num = []
t = 0
while n > 0:
	if n // 10 == 0 and n == 9:
		rev_num.append(9)
		n //= 10
	else:
		k = n % 10
		if k > 4:
			rev_num.append(9 - k)
		else:
			rev_num.append(k)
		n //= 10
num = rev_num[::-1]
print(''.join(map(str, num)))


s = ''
test = 0
for x in map(int, input()):
	if 9 - x < x:
		if 9 - x == 0:
			if test:
				s += str(9 - x)
			else:
				s += str(x)
				test = 1
		else:
			s += str(9 - x)
			test = 1
	else:
		s += str(x)
		test = 1
print(s)


import sys
x = sys.stdin.readline()
ln = len(x) - 1
i = 0
res = []
if x[i] == '9':
	res.append('9')
	i += 1
for j in range(i, ln):
	if int(x[j]) >= 5:
		res.append(str(9 - int(x[j])))
	else:
		res.append(x[j])
print(''.join(res))


n = int(input())
m = 1
k = 0
while n > 0:
	if n % 10 > 4 and n != 9:
		k = k + (9 - n % 10) * m
	else:
		k = k + n % 10 * m
	m = m * 10
	n = n // 10
print(k)


x = str(input())
y = ''
if x[0] == '9':
	y += x[0]
	x = x[1:]
for i in x:
	if i <= '4':
		y += i
	else:
		y += str(9 - int(i))
print(int(y))


n1 = int(input())
s1 = str(n1)
l1 = []
if s1[0] != '9':
	print
	s2 = str(min(int(s1[0]), 9 - int(s1[0])))
else:
	s2 = '9'
for i in range(1, len(s1)):
	s2 += str(min(int(s1[i]), 9 - int(s1[i])))
print(s2)


s = list(input())
ln = len(s)
for i in range(ln):
	s[i] = chr(48 + min(ord(s[i]) - 48, ord('9') - ord(s[i])))
if s[0] == '0':
	s[0] = '9'
print(''.join(s))


s = input()
l = []
for i in range(len(s)):
	if int(s[0]) == 9 and i == 0:
		l.append(9)
		continue
	if int(s[i]) > 4:
		l.append(9 - int(s[i]))
	else:
		l.append(int(s[i]))
s1 = ''
for i in range(len(l)):
	s1 = s1 + str(l[i])
print(s1)


from sys import stdin, stdout, setrecursionlimit
input = stdin.readline
flush = stdout.flush
OUT = []

def write(item, sep=' '):
	if type(item) is int:
		OUT.append(str(item))
	elif type(item) is list:
		if type(item[0]) is int:
			OUT.append(sep.join(map(str, item)))
		else:
			OUT.append(sep.join(item))
	else:
		OUT.append(item)

def PRINT():
	print('\n'.join(OUT))
GI = lambda : int(input())
GS = lambda : input()[:-1]
gi = lambda : list(map(int, input().split()))
gs = lambda : input().split()
n = GS()
write(''.join((min(i, str(9 - int(i))) if i < '9' or j > 0 else i for (j, i) in enumerate(n))) or '0')
PRINT()


n = input()
res_num = ''
if int(n[0]) == 9:
	res_num += '9'
else:
	res_num += str(min(int(n[0]), 9 - int(n[0])))
for i in range(1, len(n)):
	res_num += str(min(int(n[i]), 9 - int(n[i])))
res_num = int(res_num)
if res_num == 0:
	res_num = int(n) % 10
	if res_num == 0:
		res_num = 9
print(res_num)


s = input()
n = len(s)
ss = []
x = int(s[0])
if x > 9 - x and x != 9:
	ss.append(9 - x)
else:
	ss.append(x)
for i in range(1, n):
	x = int(s[i])
	x = min(x, 9 - x)
	ss.append(x)
for i in range(n):
	print(ss[i], end='')


n = [int(d) for d in input()]
v = [d if d < 9 - d else 9 - d for d in n]
if v[0] == 0:
	v[0] = 9
print(''.join([str(d) for d in v]))


n = input()
s = ''
for i in n:
	if 9 - int(i) < int(i):
		if 9 - int(i) == 0:
			if s != '':
				s += str(9 - int(i))
			else:
				s += i
		else:
			s += str(9 - int(i))
	else:
		s += i
print(s)


x = list(input())
if int(x[0]) in range(5, 9):
	x[0] = str(9 - int(x[0]))
for i in range(1, len(x)):
	if int(x[i]) in range(5, 10):
		x[i] = str(9 - int(x[i]))
print(''.join(x))


s = input()
ans = ''
for c in s:
	i = int(c)
	if i <= 4:
		ans += str(i)
	else:
		ans += str(9 - i)
if ans[0] == '0':
	ans = '9' + ans[1:]
print(int(ans))


from sys import stdin, stdout
INF = 100000000000.0

def get_int():
	return int(stdin.readline().strip())

def get_ints():
	return map(int, stdin.readline().strip().split())

def get_array():
	return list(map(int, stdin.readline().strip().split()))

def get_string():
	return stdin.readline().strip()

def op(c):
	return stdout.write(c)
s = get_string()
arr = [c for c in s]
ans = ''
for i in range(len(arr)):
	if i == 0:
		if arr[0] == '9':
			ans += arr[0]
			continue
	if int(arr[i]) >= 5:
		arr[i] = str(9 - int(arr[i]))
	ans += arr[i]
print(ans)


s = input()
for i in range(0, len(s)):
	if i == 0 and s[0] == '9':
		print('9', end='')
	elif s[i] > '4':
		print(chr(9 - (ord(s[i]) - ord('0')) + ord('0')), end='')
	else:
		print(s[i], end='')


from sys import stdin

def read():
	return stdin.readline().strip()
a = [int(x) if 9 - int(x) > int(x) else 9 - int(x) for x in str(read())]
if a[0] == 0:
	a[0] = 9
print(*a, sep='')


n = int(input())
o = len(str(n))
s = ''
i = 0
while n:
	i += 1
	x = n % 10
	if i == o and x == 9:
		s += '9'
	else:
		s += str(min(x, 9 - x))
	n //= 10
print(s[::-1])


number = list(input())
inverted_number = ''
for i in range(len(number)):
	if 9 - int(number[i]) < int(number[i]):
		if i == 0 and int(number[i]) == 9:
			inverted_number += '{}'.format('9')
		else:
			inverted_digit = 9 - int(number[i])
			inverted_number += '{}'.format(inverted_digit)
	else:
		inverted_number += '{}'.format(number[i])
print(int(inverted_number))


def convert(list):
	s = [str(i) for i in list]
	res = int(''.join(s))
	return res
x = input()
answer = []
for i in range(len(x)):
	if 9 - int(x[i]) <= int(x[i]):
		answer.append(9 - int(x[i]))
	else:
		answer.append(int(x[i]))
if answer[0] == 0:
	answer[0] = 9
print(convert(answer))


def main():
	num = list(input())
	for i in range(len(num)):
		if int(num[i]) > 4 and (not (i == 0 and int(num[i]) == 9)):
			num[i] = str(9 - int(num[i]))
	print(''.join(num))
main()


N = int(input())
s = str(N)
ans = ''
if s[0] == '9':
	ans += str(s[0])
	for i in range(1, len(s)):
		if int(s[i]) >= 5:
			x = 0
			x = 9 - int(s[i])
			ans += str(x)
		else:
			ans += str(s[i])
	ans = ans.lstrip('0')
	print(ans)
else:
	for i in range(len(s)):
		if int(s[i]) >= 5:
			x = 0
			x = 9 - int(s[i])
			ans += str(x)
		else:
			ans += str(s[i])
	ans = ans.lstrip('0')
	print(ans)


n = input()
m = {}
for i in range(10):
	m[str(i)] = str(i) if i < 5 else str(9 - i)
print(''.join(('9' if c == '9' and i == 0 else m[c] for (i, c) in enumerate(n))))


s = input()
ans = ''
if s[0] == '9':
	ans += '9'
	for i in s[1:]:
		ans += str(min(int(i), 9 - int(i)))
else:
	for i in s:
		ans += str(min(int(i), 9 - int(i)))
print(ans)


a = int(input())
n = []
i = 0
s = ''
while a != 0:
	n.append(a % 10)
	a = a // 10
b = n
l = len(n)
for i in range(l):
	if n[i] > 4:
		n[i] = 9 - n[i]
n.reverse()
if n[0] == 0:
	n[0] += 9
for i in range(l):
	s = s + str(n[i])
print(s)


s = input()
ans = ''
i = 0
for x in s:
	n = int(x)
	min_val = min(n, 9 - n)
	if min_val == 0 and i == 0:
		print(n, end='')
	else:
		print(min_val, end='')
	i = 1


n = int(input())
ns = [int(a) for a in str(n)]
ns2 = [str(min(a, 9 - a)) for a in ns]
if ns2[0] == '0':
	ns2[0] = '9'
print(int(''.join(ns2)))


x = int(input())
p = str(x)
q = ''
if p[0] == '9' or int(p[0]) < 5:
	q = q + p[0]
else:
	q = q + str(9 - int(p[0]))
for i in range(1, len(p)):
	if int(p[i]) >= 5:
		q = q + str(9 - int(p[i]))
	else:
		q = q + p[i]
print(int(q))


a = input()
b = a[0]
ans = b if int(b) < 5 or int(b) == 9 else str(9 - int(b))
for i in a[1:]:
	j = int(i)
	if j > 4:
		ans += str(9 - j)
	else:
		ans += i
print(str(int(ans)))


import os
a = 0
s = input()
for x in range(0, len(s)):
	if int(s[x]) > 9 - int(s[x]):
		if int(s[x]) == 9 and x == 0:
			a = 9
		else:
			a = a * 10 + 9 - int(s[x])
	else:
		a = a * 10 + int(s[x])
print(a)


n = input()
n = list(n)
for i in range(len(n)):
	if int(n[i]) == 9:
		n[i] = '0'
	elif int(n[i]) > 4:
		n[i] = 9 - int(n[i])
if n[0] == '0':
	n[0] = '9'
for i in range(len(n)):
	print(n[i], end='')


def sol():
	A = input()
	n = len(A)
	B = ''
	flag = True
	for i in range(n):
		if flag and int(A[i]) == 9 and (i == 0):
			B += A[i]
			continue
		else:
			flag = False
		if int(A[i]) > 4:
			B += str(9 - int(A[i]))
		else:
			B += A[i]
	print(B)
sol()


l = [min(c, str(9 - int(c))) for c in input()]
if l[0] == '0':
	l[0] = '9'
print(*l, sep='')


l = [int(x) for x in list(input())]
for i in range(len(l)):
	if l[i] > 9 - l[i]:
		l[i] = 9 - l[i]
	if not i:
		if not l[i]:
			l[i] = 9
	print(l[i], end='')


x = input()
n = len(x)
tab = []
sol = 0
for i in range(n):
	tab += [int(x[i])]
c = 0
if 4 < tab[0] < 9:
	tab[0] = 9 - tab[0]
for i in range(1, n):
	if tab[i] >= 5:
		tab[i] = 9 - tab[i]
for i in range(n):
	sol += tab[i] * 10 ** (n - 1 - i)
print(sol)


t = {'5': '4', '6': '3', '7': '2', '8': '1'}
s = input()
print(t.get(s[0], s[0]), end='')
t['9'] = '0'
for c in s[1:]:
	print(t.get(c, c), end='')


s = input()
a = [int(x) for x in s]
i = 0
while i < len(a) and a[i] == 0:
	i += 1
a = a[i:]
b = a[:]
for i in range(len(a)):
	if i == 0 and a[i] == 9:
		continue
	if a[i] > 4:
		a[i] = 9 - a[i]
i = len(a) - 1
if sum(a) == 0:
	while i >= 0 and b[i] == 0:
		i -= 1
	a[i] = b[i]
i = 0
while i < len(a):
	print(a[i], end='')
	i += 1


s = input()
if s[0] == '9' or s[0] == '1' or s[0] == '2' or (s[0] == '3') or (s[0] == '4'):
	print(int(s[0]), end='')
else:
	print(9 - int(s[0]), end='')
for i in range(1, len(s)):
	if s[i] <= '4':
		print(int(s[i]), end='')
	else:
		print(9 - int(s[i]), end='')


n = list(input())
a = ''
if n[0] == '9':
	a = '9'
	del n[0]
for i in n:
	if int(i) < 5:
		a += i
	else:
		a += str(9 - int(i))
print(int(a))


x = int(input())
y = str(x)
z = len(y)
w = ''
if y[0] == '9':
	w = w + '9'
for r in range(z):
	t = int(y[r])
	if y[0] == '9':
		if r == 0:
			r = r + 1
		elif 9 - t < t:
			w = w + str(9 - t)
		else:
			w = w + str(t)
	elif 9 - t < t:
		w = w + str(9 - t)
	else:
		w = w + str(t)
print(w)


s = input()
s1 = [str(min(int(x), 9 - int(x))) for x in s]
if s1[0] == '0':
	s1[0] = '9'
print(''.join(s1))


n = input()
r = 0
for i in range(len(n)):
	r *= 10
	if int(n[i]) > 4:
		if i == 0 and int(n[i]) == 9:
			r += int(n[i])
			continue
		r += 9 - int(n[i])
	else:
		r += int(n[i])
print(r)


x = input()
o = ''
if x[0] != '9':
	for i in x:
		o += str(min(9 - int(i), int(i)))
else:
	o += '9'
	for i in x[1:]:
		o += str(min(9 - int(i), int(i)))
print(o)


s = input()
v = []
p = ''
for i in range(len(s)):
	if int(s[i]) > 4:
		p = 9 - int(s[i])
		k = s[i].replace(s[i], str(p))
		v.append(k)
	else:
		v.append(s[i])
j = ''.join(v)
if int(j[0]) < 1:
	p = '9' + j[1:]
	print(p)
else:
	print(j)


n = list(map(int, list(input())))
for k in range(len(n)):
	if k != 0 or n[k] != 9:
		n[k] = min(n[k], 9 - n[k])
print(''.join(map(str, n)))


x = input()
x1 = ''
if ord(x[0]) >= 53 and ord(x[0]) < 57:
	x1 += chr(105 - ord(x[0]))
else:
	x1 += x[0]
for i in range(1, len(x)):
	if ord(x[i]) >= 53 and ord(x[i]) <= 57:
		x1 += chr(105 - ord(x[i]))
	else:
		x1 += x[i]
print(x1)


k = ''
for i in map(int, input().replace('', ' ').split()):
	if len(k):
		k += str(min(i, 9 - i))
	else:
		k += '9' if i == 9 else str(min(i, 9 - i))
print(k)


s = input()
first = True
for i in s:
	ch = int(i)
	if first:
		if ch >= 5 and ch < 9:
			print(9 - ch, end='')
		else:
			print(ch, end='')
		first = False
	elif ch >= 5:
		print(9 - ch, end='')
	else:
		print(ch, end='')


n1 = input()
n = list(n1)
if int(n[0]) > 4 and int(n[0]) < 9:
	n[0] = str(9 - int(n[0]))
for i in range(1, len(n)):
	if int(n[i]) > 4:
		n[i] = str(9 - int(n[i]))
st = ''.join(n)
print(st)


n = input()
if int(n[0]) == 0 or int(n[0]) == 9:
	print('9', end='')
elif int(n[0]) < 5:
	print(n[0], end='')
else:
	print(9 - int(n[0]), end='')
for i in range(1, len(n)):
	if int(n[i]) < 5:
		print(n[i], end='')
	else:
		print(9 - int(n[i]), end='')


number = input()
printed = False
for i in map(int, number):
	if i == 9 and (not printed):
		new = 9
		printed = True
	elif i > 4:
		new = 9 - i
		printed = True
	else:
		new = i
		printed = True
	print(new, end='')
print('')


x = str(input())
y = list(x)
q = ''
for i in range(0, len(x)):
	z = y[i]
	z = int(z)
	if z == 9 and i == 0:
		q = q + str(9)
	elif z >= 5:
		z = 9 - z
		q = q + str(z)
	else:
		q = q + str(z)
print(q)


s = input()
s1 = len(s)
s2 = ''
j = 0
if s[0] == '9':
	s2 += '9'
	j = 1
for i in range(j, s1):
	if int(s[i]) > 9 - int(s[i]):
		s2 += str(9 - int(s[i]))
	else:
		s2 += s[i]
print(s2)


x = input()
ans = ''
flag = True
for ch in x:
	if ch == '9' and flag:
		ans += ch
	else:
		num = ord(ch) - ord('0')
		if num >= 5:
			num = 9 - num
		ans += chr(num + ord('0'))
	flag = False
print(ans)


n = input()
l = []
l1 = []
for i in n:
	j = 9 - int(i)
	l.append(str(j))
for i in range(len(n)):
	if i == 0 and n[0] == '9':
		l1.append(n[i])
	elif n[i] <= l[i]:
		l1.append(n[i])
	else:
		l1.append(l[i])
print(''.join(l1))


num = input()
if ord(num[0]) >= ord('5') and num[0] != '9':
	ans = chr(9 - (ord(num[0]) - ord('0')) + ord('0'))
else:
	ans = num[0]
for i in range(1, len(num)):
	if ord(num[i]) >= ord('5'):
		ans += chr(9 - (ord(num[i]) - ord('0')) + ord('0'))
	else:
		ans += num[i]
print(ans)


n = input()
p = n[0]
if int(p) == 9:
	s = '9'
	i = 1
else:
	s = ''
	i = 0
while i < len(n):
	if int(n[i]) > 4:
		s = s + str(9 - int(n[i]))
	else:
		s = s + n[i]
	i = i + 1
print(int(s))


n = input()
a = []
for i in n:
	a.append(int(i))
r = ''
if a[0] != 9:
	a[0] = min(a[0], 9 - a[0])
	r = r + str(a[0])
else:
	r = str(a[0])
for i in range(1, len(a)):
	a[i] = min(a[i], 9 - a[i])
	r = r + str(a[i])
print(r)


import sys
import math
from functools import reduce
import bisect

def getN():
	return int(input())

def getNM():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def input():
	return sys.stdin.readline().rstrip()

def index(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	return False
n = input()
num = [0] * len(n)
for i in range(len(n)):
	if i == 0 and n[i] == '9':
		num[i] = n[i]
		continue
	if 9 - int(n[i]) < int(n[i]):
		num[i] = str(9 - int(n[i]))
	else:
		num[i] = n[i]
print(''.join(num))


def inv(c):
	if '5' <= c <= '9':
		return chr(ord('9') - ord(c) + ord('0'))
	return c
a = input().split()[0]
ans = ''
if a[0] != '9':
	ans += inv(a[0])
else:
	ans += '9'
for i in range(1, len(a)):
	ans += inv(a[i])
print(ans)


n = list(input())
s = ''
if int(n[0]) == 5 or int(n[0]) == 6 or int(n[0]) == 7 or (int(n[0]) == 8):
	n[0] = 9 - int(n[0])
s = s + str(n[0])
for i in range(1, len(n)):
	if int(n[i]) == 5 or int(n[i]) == 6 or int(n[i]) == 7 or (int(n[i]) == 8) or (int(n[i]) == 9):
		n[i] = 9 - int(n[i])
		s = s + str(n[i])
	else:
		s = s + n[i]
print(s)


s = input()
z = int(s[0])
if z > 4 and z != 9:
	s = str(9 - z) + s[1:]
for i in range(1, len(s) - 1):
	n = int(s[i])
	if n > 4:
		s = s[0:i] + str(9 - n) + s[i + 1:]
m = int(s[-1])
if m > 4 and len(s) != 1:
	s = s[0:-1] + str(9 - m)
print(s)


import sys
x = str(input())
ans = []
for i in x:
	t = int(i)
	t = min([t, 9 - t])
	ans.append(t)
if ans[0] == 0:
	ans[0] = 9
if not any(ans):
	print(9)
else:
	print(''.join(map(str, ans)))


def main():
	str = input()
	for (i, ch) in enumerat(str):
		ch = int(ch)
		if i == 0 and ch == 9:
			print(9, end='')
		else:
			print(min(ch, 9 - ch), end='')

def enumerat(sequence, start=0):
	n = start
	for elem in sequence:
		yield (n, elem)
		n += 1
main()


try:
	num = int(input())
	newnum = 0
	i = 0
	rip = 0
	while num != 0:
		rip = num % 10
		if rip >= 5:
			newnum += (9 - rip) * 10 ** i
		else:
			newnum += rip * 10 ** i
		i += 1
		num = num // 10
	if rip == 9:
		newnum += 9 * 10 ** (i - 1)
	print(newnum)
except:
	pass


n = input()
n = list(n)
for i in range(0, len(n)):
	m = 9 - int(n[i])
	t = int(n[i])
	if i == 0 and m == 0:
		abc = 1
	elif m < t:
		n[i] = str(m)
print(*n, sep='')


n = int(input())
z = list(str(n))
for i in range(len(z)):
	if i == 0:
		if z[0] == '9':
			print(z[0], end='')
			continue
	if int(z[i]) > 9 - int(z[i]):
		z[i] = 9 - int(z[i])
	print(z[i], end='')


x = input()
ans = ''
for i in range(len(x)):
	if i == 0 and x[i] == '9':
		ans += x[i]
		continue
	if '5' <= x[i] <= '9':
		ans += str(9 - int(x[i]))
	else:
		ans += x[i]
print(ans)


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
number = read_str()
ans = ''
for (i, v) in enumerate(number):
	x = min(int(v), 9 - int(v))
	if i == 0 and x < 1:
		ans += '9'
	else:
		ans += str(x)
print(ans)


x = str(input())
new = ''
for i in range(len(x)):
	if i == 0 and 9 - int(x[i]) == 0:
		new += str(x[i])
	elif 9 - int(x[i]) <= int(x[i]):
		new += str(9 - int(x[i]))
	else:
		new += str(x[i])
print(new)


n = input()
a = []
for i in range(len(n)):
	a.append(min(int(n[i]), 9 - int(n[i])))
if a[0] == 0:
	a[0] += 9
for i in a:
	print(i, end='')


number2 = str()
number = input()
for i in range(len(number)):
	if (i == 0) & (number[i] == '9'):
		number2 = number2 + '9'
	elif int(number[i]) > 4:
		number2 = number2 + str(9 - int(number[i]))
	else:
		number2 = number2 + number[i]
print(number2)


L = list(input())
for i in range(len(L)):
	a = L[i]
	if int(a) < 5:
		continue
	b = 9 - int(a)
	L[i] = str(b)
if L[0] == '0':
	L[0] = '9'
print(''.join(L))


n = int(input())
res = 0
index = 0
while n >= 10:
	x = n % 10
	temp = min(x, 9 - x)
	res += temp * 10 ** index
	index += 1
	n //= 10
if n != 9:
	temp = min(n, 9 - n)
	res += temp * 10 ** index
else:
	res += 9 * 10 ** index
print(res)


S = list(input())
for i in range(len(S)):
	x = int(S[i])
	y = 9 - x
	if y < x and (y != 0 or i != 0):
		S[i] = str(y)
print(''.join(S))


n = int(input())
a = []
while n > 0:
	x = n % 10
	a.append(str(min(x, 9 - x)))
	n = n // 10
a = a[::-1]
if x == 9:
	a[0] = '9'
print(''.join(map(str, a)))


x = input('')
ans = ''
for j in range(len(x)):
	i = x[j]
	if int(i) == 9:
		if j > 0:
			ans += str(9 - int(i))
		else:
			ans += i
	elif int(i) >= 5:
		ans += str(9 - int(i))
	else:
		ans += i
print(ans)


num = input()
if 9 - int(num[0]) < int(num[0]) and num[0] != '9':
	print(9 - int(num[0]), end='')
else:
	print(num[0], end='')
for i in range(1, len(num)):
	if 9 - int(num[i]) < int(num[i]):
		print(9 - int(num[i]), end='')
	else:
		print(num[i], end='')


def main():
	from sys import stdin, stdout
	n = stdin.readline().strip()
	s = ''
	for i in range(len(n)):
		if int(i):
			j = min(int(n[i]), 9 - int(n[i]))
			s += str(j)
		elif int(n[i]) == 9:
			s += '9'
		else:
			j = min(int(n[i]), 9 - int(n[i]))
			s += str(j)
	stdout.write(s)
main()


n = str(input())
ans = ''
x = 0
for i in n:
	if 9 - int(i) < int(i) and (9 - int(i) != 0 or x != 0):
		ans += str(9 - int(i))
	else:
		ans += i
	x += 1
print(ans)


n = int(input())
l = []
while n:
	l.insert(0, n % 10)
	n = n // 10
for i in range(len(l)):
	if l[i] < 9 - l[i] or (l[i] == 9 and i == 0):
		print(l[i], end='')
	else:
		print(9 - l[i], end='')


n = input()
y = ''
for x in list(range(len(n))):
	if x == 0 and int(n[x]) == 9:
		y = y + str(n[x])
	elif int(n[x]) > 9 - int(n[x]):
		z = 9 - int(n[x])
		y = y + str(z)
	else:
		y = y + str(n[x])
print(int(y))


n = input()
f = 0
s = ''
for i in n:
	if f == 0:
		if i >= '5' and i != '9':
			s += str(9 - int(i))
		else:
			s += i
		f = 1
	elif i >= '5':
		s += str(9 - int(i))
	else:
		s += i
print(s)


s = input()
ns = ''
for (i, x) in enumerate(s):
	if '5' <= x <= '8':
		ns += chr(ord('0') + 9 - (ord(x) - ord('0')))
	elif x == '9' and i:
		ns += '0'
	else:
		ns += x
print(ns)


f = lambda x: min(int(x), 9 - int(x))
s = input()
print(9 if s[0] == '9' else f(s[0]), end='')
for i in s[1:]:
	print(f(i), end='')


num = input()
num = [int(i) for i in num]
for i in range(1, num.__len__()):
	if num[i] > 4:
		num[i] = 9 - num[i]
	else:
		num[i] = num[i]
if num[0] > 4 and num[0] != 9:
	num[0] = 9 - num[0]
num = [str(i) for i in num]
num = ''.join(num)
print(num)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase
from fractions import *

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = input()
ans = ''
if n[0] == '9':
	ans = '9'
else:
	ans = str(min(9 - int(n[0]), int(n[0])))
for i in range(1, len(n)):
	ans += str(min(9 - int(n[i]), int(n[i])))
print(ans)


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
mp = lambda : list(map(int, cin().split()))
s = cin()[:-1]
y = ''
a = int(s[0])
y += str((a < 9) * min(a, 9 - a) + (a == 9) * 9)
for ch in s[1:]:
	a = int(ch)
	y += str(min(a, 9 - a))
cout(y)


n = list(map(int, list(input())))
if 9 > n[0] >= 5:
	n[0] = 9 - n[0]
for i in range(1, len(n)):
	if n[i] >= 5:
		n[i] = 9 - n[i]
for item in n:
	print(item, end='')


n = list(input())
if int(n[0]) == 9:
	for i in range(1, len(n)):
		if int(n[i]) >= 5:
			n[i] = str(9 - int(n[i]))
else:
	for i in range(0, len(n)):
		if int(n[i]) >= 5:
			n[i] = str(9 - int(n[i]))
string = ''
for i in n:
	string += i
print(string)


k = []
for (j, i) in enumerate(map(int, input())):
	if j == 0 and 9 - i == 0:
		k.append(i)
	elif 9 - i > i:
		k.append(i)
	else:
		k.append(9 - i)
print(''.join(map(str, k)))


x = [int(x) for x in input()]
i = 0
new = []
for letter in x:
	if letter == 9 and i == 0:
		new.append(letter)
	elif letter > 4:
		new.append(9 - letter)
	else:
		new.append(letter)
	i += 1
print(''.join([str(x) for x in new]))


import sys

def solve():
	n = list(input())
	for i in range(len(n)):
		if int(n[i]) > 4 and (i != 0 or int(n[i]) != 9):
			n[i] = str(9 - int(n[i]))
	return n

def read(mode=2):
	inputs = input().strip()
	if mode == 0:
		return inputs
	if mode == 1:
		return inputs.split()
	if mode == 2:
		return list(map(int, inputs.split()))

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, list):
		s = ''.join(map(str, s))
	if isinstance(s, tuple):
		s = ''.join(map(str, s))
	s = str(s)
	print(s, end='')

def run():
	if sys.hexversion == 50594544:
		sys.stdin = open('test.txt')
	res = solve()
	write(res)
run()


x = int(input())
x_s = str(x)
for i in range(len(x_s)):
	new_x = list(x_s)
	new_x[i] = str(9 - int(new_x[i]))
	if int(''.join(new_x)) < x and int(''.join(new_x)) >= 0 and (''.join(new_x)[0] != '0'):
		x = int(''.join(new_x))
		x_s = ''.join(new_x)
print(x)


inp = input()
mod_inp = [int(x) for x in inp[1:]]
out = []
for i in mod_inp:
	if i > 4:
		i = 9 - i
	out.append(i)
x = int(inp[0])
if x > 4 and x != 9:
	x = 9 - x
out = str(x) + str(''.join((str(i) for i in out)))
print(out)


x = input()
ch = ''
i = 0
if int(x[i]) > 4 and int(x[i]) < 9:
	a = 9 - int(x[i])
	ch += str(a)
	i += 1
else:
	ch += str(x[i])
	i += 1
while i < len(x):
	if int(x[i]) > 4:
		a = 9 - int(x[i])
		ch += str(a)
		i += 1
	else:
		ch += str(x[i])
		i += 1
ch = int(ch)
print(ch)


n = input().rstrip()
x = list(n)
for i in range(0, len(x)):
	g = int(x[i])
	t = 9 - int(x[i])
	if i == 0:
		if t == 0:
			x[i] = str(g)
		else:
			f = min(g, t)
			x[i] = str(f)
	else:
		f = min(g, t)
		x[i] = str(f)
C = ''.join(x)
print(C)


n = input()
arr = []
for digit in n:
	arr.append(digit)
if 9 - int(arr[0]) < int(arr[0]) and arr[0] != '9':
	arr[0] = str(int(9 - int(arr[0])))
for i in range(1, len(arr)):
	if 9 - int(arr[i]) < int(arr[i]):
		arr[i] = str(int(9 - int(arr[i])))
res = int(''.join(arr))
print(res)


is_debug = False
s = input()
l = len(s)
for i in range(l):
	x = int(s[i])
	if i == 0 and x >= 5 and (9 - x != 0) or (i != 0 and x >= 5):
		x = 9 - x
	print(f'{x}', end='')
print()


n = list(input())
pa = 0
for x in range(len(n)):
	if 9 - int(n[x]) >= int(n[x]):
		pa += 1
	else:
		n[x] = str(9 - int(n[x]))
		if n[x] != '0':
			pa += 1
		elif pa >= 1:
			pass
		else:
			n[x] = str(9)
			pa += 1
print(''.join(n))


n = int(input())
aux = 0
p = 1
while n >= 10:
	aux = aux + min(9 - n % 10, n % 10) * p
	p = p * 10
	n //= 10
if n == 9:
	aux = aux + 9 * p
else:
	aux = aux + min(9 - n % 10, n % 10) * p
print(aux)


n = input()
y = int(n)
up = [5, 6, 7, 8, 9]
res = []
for i in range(len(n)):
	last = int(n[len(n) - (i + 1)])
	if last in up:
		last = 9 - last
		res.append(str(last))
	else:
		res.append(str(last))
res = res[::-1]
if res[0] == '0':
	res[0] = '9'
	print(''.join(res))
else:
	print(''.join(res))


x = input()
for i in range(len(x)):
	if x[0] == '9':
		if 9 - int(x[i]) < int(x[i]):
			x = x[0] + x[1:].replace(str(x[i]), str(9 - int(x[i])))
	elif 9 - int(x[i]) < int(x[i]):
		x = x.replace(str(x[i]), str(9 - int(x[i])))
print(x)


while True:
	try:
		s = input()
		ans = ''
		if s[0] == '9':
			ans += '9'
		elif int(s[0]) >= 5:
			ans += str(9 - int(s[0]))
		else:
			ans += s[0]
		for i in range(1, len(s)):
			if int(s[i]) >= 5:
				ans += str(9 - int(s[i]))
			else:
				ans += s[i]
		print(ans)
	except EOFError:
		break


x = input()
arr = list(map(int, list(x)))
flag = False
for i in range(len(arr)):
	if arr[i] >= 5:
		if arr[i] != 9 or flag:
			arr[i] = 9 - arr[i]
	flag = True
print(''.join(list(map(str, arr))))


s = input()
s = ' '.join(s)
s = s.split()
ans = []
for i in range(0, len(s)):
	if i == 0 and int(s[i]) > 8:
		ans.append(int(s[i]))
	elif int(s[i]) > 4:
		ans.append(9 - int(s[i]))
	else:
		ans.append(int(s[i]))
n = str(ans)
n = n.replace('[', '')
n = n.replace(']', '')
n = n.replace(',', '')
n = n.replace(' ', '')
print(n)


s = input()
r = ''
for c in s:
	k = int(c)
	r += str([k, 9 - k][k > 4])
if r[0] == '0':
	print(s[0] + r[1:])
else:
	print(r)


n = str(input())
o = ''
if n[0] == '9':
	o = '9'
	n = n[1:]
else:
	o = ''
inDict = {'5': '4', '6': '3', '7': '2', '8': '1', '9': '0'}
for x in range(len(n)):
	if n[x] > '4':
		o += inDict[n[x]]
	else:
		o += n[x]
print(o)


n = input()
out = ''
for c in n:
	if int(c) < 9 - int(c):
		out += c
	else:
		out += str(9 - int(c))
if int(out[0]) == 0:
	print(n[0] + out[1:])
else:
	print(out)


n = input()
digits = []
for letter in n:
	digits.append(int(letter))
for i in range(len(digits)):
	if i == 0:
		if digits[i] == 9:
			pass
		elif digits[i] > 4:
			digits[i] = 9 - digits[i]
	elif digits[i] > 4:
		digits[i] = 9 - digits[i]
for element in digits:
	print(element, end='')


in_num = int(input())
out_num = 0
times = 0
while True:
	tem = int(in_num % 10)
	if int(in_num / 10) == 0 and tem == 9:
		pass
	elif int(in_num / 10) != 0 and tem >= 5 or (int(in_num / 10) == 0 and tem != 9 and (tem >= 5)):
		tem = 9 - tem
	out_num = int(tem * 10 ** times) + out_num
	times = times + 1
	in_num = int(in_num // 10)
	if in_num == 0:
		break
print(out_num)


k = input()
x = int(k)
k = ' '
min_number = x
array_one = str(x)
array_two = []
array_third = []
c = len(array_one)
for i in range(c):
	array_two.append(int(array_one[i]))
	array_third.append(int(array_one[i]))
k2 = 0
if array_two[0] == 9:
	summ = 1
else:
	summ = 0
for i in range(summ, c):
	array_two[i] = 9 - array_two[i]
	if array_two[i] < array_third[i]:
		for j in range(c):
			k = k + str(array_two[j])
		number_two = int(k)
		if number_two < min_number:
			min_number = number_two
		k = ' '
	else:
		array_two[i] = 9 - array_two[i]
print(min_number)


n = input()
for i in range(len(n)):
	if i > 0 or (i == 0 and n[i] != '9'):
		print('', end=str(min(int(n[i]), 9 - int(n[i]))))
	else:
		print(end='9')
print()


a = input()
a = list(a)
for i in range(len(a)):
	if int(a[i]) > 4:
		a[i] = str(9 - int(a[i]))
if int(a[0]) == 0:
	a[0] = str(9)
a = ''.join(a)
print(a)