Problems > All Digits Different

All Digits Different

Difficulty: 1700 2000 ms 128 MB

math

Count the integers in [1, N] whose decimal digits are all DISTINCT.

Input: one integer N.

Output: the count of repeat-free numbers up to N.

Constraints:

  • 1 ≤ N ≤ 1018

Sample Tests

Input 1
20
Output 1
19
Input 2
100
Output 2
90

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.