P27001 [AtCoder] Lucky PIN
普及
题目描述

Problem Description

AtCoder Inc. has decided to set a 3-digit passcode at the entrance of their office.

AtCoder Inc. has an N-digit lucky number S. Takahashi, the president, decided to set the passcode by removing N-3 digits from S and reading the remaining 3 digits from left to right.

How many different passcodes can be set in this way?

Note that both the lucky number and the passcode may start with a 0.

Input Format

The input is given from the standard input in the following format:

$ N $ $ S $

Output Format

Output the number of different passcodes that can be set.

Sample Input and Output

Sample Input #1

4
0224

Sample Output #1

3

Sample Input #2

6
123123

Sample Output #2

17

Sample Input #3

19
3141592653589793238

Sample Output #3

329

Notes/Hints

Constraints

  • $4 \leq N \leq 30000$
  • $ S $ is a string of length $ N $ consisting of ASCII digits

Sample Explanation 1

Takahashi has the following options:
- Remove the 1st digit of $ S $ to set the passcode as 224.
- Remove the 2nd digit of $ S $ to set the passcode as 024.
- Remove the 3rd digit of $ S $ to set the passcode as 024.
- Remove the 4th digit of $ S $ to set the passcode as 022.
Thus, the possible passcodes are 022, 024, and 224, totaling 3 different passcodes.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 0224
样例输出
3