N = input() L = len(N) stack = [] for c in N: if c in '45': stack.append(c) elif c > '5': while len(stack) < L: stack.append('5') break else: while stack and stack[-1]=='4': stack.pop() if len(stack)==0: stack = ['5']*(L-1) else: stack.pop() stack.append('4') while len(stack) < L: stack.append('5') break print(''.join(stack))