## DMOPC '19 Contest 3 P2 - Generating Names

View as PDF

Points: 7 (partial)
Time limit: 1.0s
Memory limit: 64M

Authors:
Problem types
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

Veshy is trying to come up with a username for his new alt-account! Unfortunately, he is currently in a creative lull, so he has turned to permutating strings of lowercase letters of length to find a username. This was still not creative enough for Veshy, so he is currently trying to increase the number of potential candidate usernames by having wildcard characters (*) in his starting string before permutating. Since you are Veshy's absolute best friend, help him find the number of candidate usernames!

#### Input Specifications

The first line will have space-separated integers, and . The following line will have a string composed of only lowercase alphabet characters and/or the character *. There will be *'s in the string.

#### Output Specifications

Output the total number of possible permutations of the string.

#### Sample Input 1

2 1
b*

#### Sample Output 1

51

#### Sample Input 2

2 2
**

#### Sample Output 2

676

#### Explanation of Sample Input 1

There are different possibilities for the wildcard character. Out of these possibilities, result in unique permutations (e.g. ba ba and ab, bc bc and cb, etc.), and results in only unique permutation (when the wildcard character is b, to make bb). .