beecrowd | 2013

At Most Twice

By Pablo Ariel Heiber AR Argentina

Timelimit: 1

Given a positive integer U, find the largest integer L such that L ≤ U and L does not contain any digit more than twice.

Input

The input consists of a single line that contains an integer U (1 ≤ U ≤ 1018).

Output

Output a line with an integer representing the largest number less than or equal to U that does not contain any digit more than twice.

Input Samples Output Samples

2210102960

2210099887

1000000000000000000

998877665544332211

1001223343

998877665

20152015

20152015