LogiQuest

486. Count Consistent Strings

EasyHash Set

A word is consistent if all its letters are in allowed. Print how many words are consistent.

Input format

Line 1: allowed Line 2: n Line 3: n words

Output format

The count.

Example 1

Input

ab
5
ad bd aaab baa badab

Output

2

Example 2

Input

abc
7
a b c ab ac bc abc

Output

7

Constraints

1 ≤ n ≤ 10⁴

Read input from standard input and print the answer to standard output. Your code is judged against 3 test cases, most of them hidden.

Loading the MyLoginn IDE…