atcoder#SUMITB2019D. Lucky PIN

Lucky PIN

Score: 400400 points

Problem Statement

AtCoder Inc. has decided to lock the door of its office with a 33-digit PIN code.

The company has an NN-digit lucky number, SS. Takahashi, the president, will erase N3N-3 digits from SS and concatenate the remaining 33 digits without changing the order to set the PIN code.

How many different PIN codes can he set this way?

Both the lucky number and the PIN code may begin with a 00.

Constraints

  • 4N300004 \leq N \leq 30000
  • SS is a string of length NN consisting of digits.

Input

Input is given from Standard Input in the following format:

NN

SS

Output

Print the number of different PIN codes Takahashi can set.

4
0224
3

Takahashi has the following options:

  • Erase the first digit of SS and set 224.
  • Erase the second digit of SS and set 024.
  • Erase the third digit of SS and set 024.
  • Erase the fourth digit of SS and set 022.

Thus, he can set three different PIN codes: 022, 024, and 224.

6
123123
17
19
3141592653589793238
329