Suitable pairs#3003

Suitable pairs

1 second
128 megabytes
Easy

We call a pair of non-negative integers suitable if their decimal representations have at least one common digit (the digit does not need to be in the same position). Let non-negative integers a_1, a_2, , a_n be given. Consider all possible pairs (a_i, a_j) where 1 \leq i < j \leq n.

Write a program to determine the number of suitable pairs among them.

Input

The first line contains a positive integer (1 \leq n \leq 10^6). The second line contains non-negative integers, each not exceeding .

Output

Print the number of suitable pairs.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading