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: interview

Starter code:

Solutions:
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)


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)


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]))
    else:
        if int(a[i]) <= 4:
            new += str(a[i])
        else:
            new += str(9-int(a[i]))
print(new)


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
        else:
            if digits[i]>4:
                digits[i]=9-digits[i]
    else:
        if digits[i]>4:
            digits[i]=9-digits[i]
for element in digits:
    print(element,end='')

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 = 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)

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))

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 = '')
    

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))


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)


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)
	return
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)))



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  # String
    if mode == 1: return inputs.split()  # List of strings
    if mode == 2: return list(map(int, inputs.split()))  # List of integers
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()

"""
Codeforces Contest 291 Div 2 Problem A

Author  : chaotic_iak
Language: Python 3.4.2
"""

################################################### SOLUTION

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)


#################################################### HELPERS



def read(mode=2):
    # 0: String
    # 1: List of strings
    # 2: List of integers
    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())

#!/usr/bin/env python3

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))))


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)))


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()
ans = ''
for i in range(len(s)):
    x = int(s[i])
    if i == 0 and x == 9:
        ans += str(x)
    elif 9 - x < x:
        ans += str(9 - x)
    else:
        ans += str(x)
print(int(ans), 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])))


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))

import sys
f = sys.stdin

s = f.readline().strip()

p = ''
start = 0
for u in s:
    #print(u,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(u, p)
    
print(p)    

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)
    else:
        if 9 - num > num:
            strN = strN + i 
        else:
            strN = strN + str(9 - num)
    counter = counter + 1
print(int(strN))


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)


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)


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

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)