Marko's T9 input

Count how many dictionary words map letter by letter to the given T9 digit string.

Easy2StringHash mapInterviewNo attempts yetTime limit2sMemory limit64 MB

Problem

Marko found a new feature on his mobile phone, T9 input. The phone has a numeric keypad laid out like this.

T9 keypad

KeyLetters
2a, b, c
3d, e, f
4g, h, i
5j, k, l
6m, n, o
7p, q, r, s
8t, u, v
9w, x, y, z

To type a word on this keypad you press the same key several times until the letter you want appears. If the letter is the first one on the key, one press is enough; if it is the second, you press twice, and so on. To type giht you press 4 for g, 444 for i, 44 for h, and 8 for t. With the feature Marko found you no longer need several presses per letter, just one, and the software works out which dictionary word you meant.

Marko distrusts technology that is new to him and expects errors to be common. He decided to test that hypothesis himself. He knows the whole phone dictionary by heart. The dictionary holds NN words made of lowercase English letters, and the total length of the words is at most 10000001000000. Given a string of key presses SS of length at most 10001000, count how many dictionary words match SS under T9 input.

Input

The first line contains the integer NN, the number of words in the dictionary. (1N10001 \le N \le 1000)

Each of the next NN lines contains one word. Every word consists of lowercase English letters, and the total length of all words is at most 10000001000000.

The last line contains the string SS consisting of the digits 2 to 9. (1S10001 \le |S| \le 1000)

Output

Print the number of dictionary words that can be spelled using only the letters on the keys given by SS.

Hint

In the first example, mono is the only word whose letters all sit on key 6.

In the second example, the first letter of both words is on key 5 and the second letter of both words is on key 2.