Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Beer And Strings Beer found a list of string recently. A game came into his mind instantaneously. The game is as awkward as beer's name

Beer And Strings

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 ith line contains ith 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|X|10000000

1n100000

1Length of ith string 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.

Moriarty and the City

Moriarty is planning to plant a bomb in the city. City is organized in such a way that only similar continuous blocks gets affected by such attacks. Moriarty have the information of the arrangement of blocks. Help him to calculate maximum number of blocks that can be destroyed.

INPUT

First line of input contains N denoting number of blocks.

Then for following N space separated number denotes type of block.

OUTPUT

Output maximum number of blocks that can be destroyed by Moriarty.

Note: Blocks are of only 2 types (0 or 1). And City is considered to be linear.

CONSTRAINTS

1<= N <= 10^8

SAMPLE INPUT

5

0 1 1 0 1

SAMPLE OUTPUT

2

Explanation

The maximum number of consecutive objects of same type is 2.

Toatl no of question is two ,Give the sol separately..

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions