#CCBCHMOT0000042. Năm có bốn chữ số phân biệt (Beautiful Year)

Năm có bốn chữ số phân biệt (Beautiful Year)

Beautiful Year

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given four-digit year y, find the smallest integer year strictly greater than y whose four decimal digits are pairwise distinct.

Input

One integer y.

Output

Print the smallest valid year strictly larger than y.

Subtasks

  • Subtask 1 (20%): 1000≤y≤10991000\le y\le1099.
  • Subtask 2 (30%): 1000≤y≤49991000\le y\le4999.
  • Subtask 3 (50%): 1000≤y≤90001000\le y\le9000.

Examples

Example 1

Input

1987

Output

2013

Explanation

Scanning years after 1987, 2013 is the first with four distinct digits.

Example 2

Input

2013

Output

2014

Explanation

The answer must be strictly greater; 2014 is the next valid year.