P29727 [洛谷] [COCI2015-2016#2] MARKO
普及
题目描述

Problem Description

Old man Marko has discovered a new feature on his phone—the nine-key input! His phone has a keyboard composed of digits, which looks like this:

 1      2 abc  3 def  
4 ghi  5 jkl   6 mno 
7 pqrs 8 tuv  9 wxyz

To input a word using this keyboard, Marko needs to press a key multiple times to get the desired letter. More specifically, if the desired letter is the first letter on the key, he presses the key once; if it's the second letter, he presses the key twice, and so on.

For example, to input the word giht, Marko needs to press 4 once for g, three times for i, twice for h, and once for t.

Marko has memorized the entire dictionary on his phone. This dictionary consists of $N$ words, each composed of lowercase English letters, with the total length of all words not exceeding $10^9$ characters. Marko will provide a set of available keys and wants to know how many words in the dictionary can be input using the given set of keys on the nine-key input.

Input Format

The first line contains an integer $N$, representing the number of words in the dictionary.

The next $N$ lines each contain a word composed of lowercase English letters.

The last line is a string $S$ composed of digits 2-9, representing the set of available keys.

Output Format

A single integer representing how many words in the dictionary can be input using the given set of keys on the nine-key input.

Sample Input and Output

Sample Input #1

3
tomo
mono
dak
6666

Sample Output #1

1

Sample Input #2

2
ja
la
52

Sample Output #2

2

Sample Input #3

3
dom
fon
tom
366

Sample Output #3

2

Notes/Hints

[Sample 1 Explanation]

The four letters of mono are all on key 6, so mono can be typed.

The other words cannot be typed.

[Sample 2 Explanation]

j is on key 5 and a is on key 2, so ja can be typed.

l is on key 5 and a is on key 2, so la can be typed.

[Data Range]

For $100\%$ of the data, $1 \le N \le 10^3$, $1 \le |S| \le 10^3$.

[Note]

This problem's score is based on the original contest, with a maximum score of 50.

This problem is translated from COCI 2015-2016 CONTEST #2 T1 MARKO.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 tomo mono dak 6666
样例输出
1