Problem list
Log in
#coci00202 · COCI 2011/2012 Contest 2

Kompići

Gold II 1.0 s 32 MB

After successfully solving his math homework from the previous task, Mirko has become bored, so he has made a list of $N$ large integers. On the list there are some pairs of numbers that he likes, and some pairs he doesn't like.

Mirko has named the pairs that he likes pals. Two numbers are pals if they have at least one digit in common (not necessarily in the same position).

Help Mirko count how many pairs of numbers in his list are pals.

Input

The first line of input contains the positive integer $N$ ($1 \le N \le 1,000,000$).

Each of the next $N$ lines contains a positive integer from the range $[1, 10^{18}]$, a number from Mirko's list. No two numbers in the list will be equal.

Output

The first and only line of output must contain the number of pairs that are pals.

Example 1

Input
3
4
20
44
Output
1

Example 2

Input
4
32
51
123
282
Output
4
Source
COCI 2011/2012 Contest 2
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code