Wordle

Time limit: 0.1s
Memory limit: 64MB
Input:
Output:

The new, popular word game Wordle spreads so fast that its contagiousness has reached Luca.

For those of you who have not yet heard about it, in Wordle you have to guess a 5-letter word in a limited number of attempts. After each attempt you get to know, for each position, whether your guess had the right letter in the right position, a letter present in the word but not in the right position, or a completely wrong letter.

Intrigued by the characteristics of the word game, Luca has decided to create his own more generic version. In this version, one needs to guess an NN-letter word. Every possible sequence of letters of the English alphabet constitutes a potentially valid guess, but it is guaranteed that the word to guess does not contain the same letter twice.

Task

You are in the middle of a game: you already guessed some letters but you still have to figure out some of them, which are indicated in the input with an underscore (_). You wonder: how many words could be a valid solution for the game, given the letters you know?

Input data

The first line of the input contains the only integer NN. The second line contains NN letters LiL_i: either an uppercase letter of the English alphabet or an underscore.

Output data

The output contains a single line with an integer: the number of possible solutions.

Constraints and clarifications

  • 3N63 \leq N \leq 6
  • For tests worth 1010 points, N=6N = 6 and the number of missing letters is always 11.
  • For tests worth 2020 more points, the number of missing letters is always 11.
  • For tests worth 3030 more points, the number of missing letters is always 11 or 22.

Example 1

stdin

5
H O U S _

stdout

22

Explanation

In the first sample case there are 2222 valid possibilities. One of the obvious ones is an E for the fifth position.

Note that B is a valid possibility too (even though it does not form a valid English word), but S is not, given that the letter is already present in the word in the fourth position.

Example 2

stdin

3
A _ _

stdout

600

Explanation

In the second sample case there are 600600 valid possibilities.

Log in or sign up to be able to send submissions!