770_B. Maximize Sum of Digits
Anton has the integer x. He is interested what positive integer, which doesn't exceed x, has the maximum sum of digits.

Your task is to help Anton and to find the integer that interests him. If there are several such integers, determine the biggest of them. 

Input

The first line contains the positive integer x (1 ≤ x ≤ 1018) — the integer which Anton has. 

Output

Print the positive integer which doesn't exceed x and has the maximum sum of digits. If there are several such integers, print the biggest of them. Printed integer must not contain leading zeros.

Examples

Input

100


Output

99


Input

48


Output

48


Input

521


Output

499
```python
num = list(input())
orgnum = num.copy()
if len(num) == 1:
    print(num[0])
elif num[1:] != list("9"*(len(num)-1)):
    if num[1:] == list("8"+"9"*(len(num)-2)):
        print(int("".join(num)))
    elif "9" in num:
        finished = False
        did = False
        for i in range(len(num)):
            if num[i] != "9" and not finished and i != 0 and i != 1 and orgnum[i-1] == "9":
                num[i-1] = "8"
                num[i] = "9"
                finished = True
                did = True
            elif i != 0:
                num[i] = "9"
            if orgnum[i-1] != "9" and i != 0 and i != 1 and not did:
                finished = True
                did = False
        for i in range(2, 13):
            if num[-i:] == ["8"] + ["9"]*(i-1):
                num[-i:] = num[-i:][::-1]
                if int("".join(orgnum)) < int("".join(num)):
                    num[-i:] = num[-i:][::-1]
        if not did:
            num[0] = str(int(num[0])-1)
        if sum([int(x) for x in num]) <= sum([int(x) for x in orgnum]):
            num = orgnum.copy()
        print(int("".join(num)))
    else:
        print(int(str(int(num[0])-1)+"9"*(len(num)-1)))
else:
    print(int("".join(num)))
```