시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 256 MB83544364.179%

문제

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

입력

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

출력

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.

예제 입력 1

2210102960

예제 출력 1

2210099887

예제 입력 2

1000000000000000000

예제 출력 2

998877665544332211

예제 입력 3

1001223343

예제 출력 3

998877665

예제 입력 4

20152015

예제 출력 4

20152015

출처

ICPC > Regionals > Latin America > Latin America Regional Contests 2015 A번

  • 문제를 만든 사람: Pablo Ariel Heiber