All problems

Problem 356

Count Numbers with Unique Digits

Medium · 20 pts · Math, Combinatorics, Dynamic Programming

Problem

Count the integers X with 0 <= X < 10^N whose decimal digits are all different. For example, 12 and 907 qualify, but 11 and 121 do not. The number 0 counts. For numbers with exactly k digits, the first digit has 9 choices (1-9), the second 9 (any digit except the first), the third 8, and so on; add these counts for k = 1 to N, plus one for 0.

Input

A single integer N.

Output

Print the count.

Constraints

0 <= N <= 10

Example input

2

Example output

91

Explanation

For N = 2 there are 100 numbers from 0 to 99. Exactly 9 of them repeat a digit (11, 22, ..., 99), so the answer is 91.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Total Hamming Distance Next: Integer Break