All Tracks Algorithms String Algorithms String Searching Problem

Beer And Strings
Tag(s):

Very-Easy

Problem
Editorial
Analytics

Beer found a list of string recently. A game came into his mind instantaneously. The game is as awkward as beer's name :D The game is how many of the strings can be made using characters of Beer's all time favorite string X

Input

First line of input contain Beer's favorite string X

Second line of the input contains a integer n number of string in the list. n line follows \(i^{th}\) line contains \(i^{th}\) string of the list.

Output

Output a single integer denoting the number of strings in the list which can be formed using letters of Beer's favorite string.

Constraints

\(1 \le |X| \le 10000000\)

\(1 \le n \le 100000\)

\(1 \le Length\) \(of\) \(i^{th}\) \(string\) \(\le 100\)

X consist of lowercase alphabets only

NOTE Please use fast I/O for this problem

SAMPLE INPUT
abcd
2
ab
ef
SAMPLE OUTPUT
1
Explanation

\(ab\) can be made using letters of \(abcd\) but \(ef\) can't be made using letters of \(abcd\)

Time Limit: 0.5 sec(s) for each input file.
Memory Limit: 2048 MB
Source Limit: 100 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

Notifications
View All Notifications

?