409574: GYM103637 B BSUIR Open X

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. BSUIR Open Xtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

At the anniversary BSUIR Open, there simply must be a task about creating tasks for BSUIR Open.

Let's start with the fact that the tasks for the anniversary BSUIR Open should be especially interesting. That is why $$$n$$$ task sets were developed for such purposes. It was assumed that among these sets the only one, the best set will be selected to be used for the competition. But then the setters realized that solving problems from one set would not be so interesting. In general, each set in itself is very interesting and would be perfect for a regular competition, but not for the anniversary BSUIR Open.

To make the competition more interesting, it was decided to take tasks immediately from two sets of tasks. Each set has its own code name, and some sets may have the same name. In order for the competition to be perfect, it is necessary that the names of these sets could be used to make the string "BSUIROPENX" by appending one string to the end of the other. For example, if we selected two task sets "FOO" and "BAR", then you can make either the string "FOOBAR" or "BARFOO".

Now that you know how to make the perfect competition for the anniversary BSUIR Open, you need to determine the number of ways to do this. Two methods are considered different if they differ in at least one set of tasks, or their order is different.

Input

The first line contains a single integer $$$n$$$ – the number of task sets.

The next $$$n$$$ lines contain lines consisting only of capital English letters – code names of task sets.

$$$$$$1 \le n \le 10^5$$$$$$

The total length of the names of the task sets does not exceed $$$10^6$$$.

Output

In a single line print a single integer – the number of ideal competitions that can be made up of the indicated sets of tasks.

ExamplesInput
4
BSUIR
BSU
OPEN
IROPENX
Output
1
Input
13
BSUIR
OPENX
BSUIR
OPENX
BSUIR
OPENX
BSUIR
OPENX
BSUIR
OPENX
BSUIR
OPENX
BSUIR
Output
42
Note

In the first test case, you can use the set "BSU" and the set "IROPENX".

加入题单

上一题 下一题 算法标签: