Cook me a character meal Chef Avillez is about to cook us some really nice meal. He is just waiting for us to give him some ingredients and to request a meal.

Task

Given a list of ingredients (strings matching /[a-z]+/) and a requested meal (string matching /[a-z][a-z ]*/) output the integer amount of meals Chef Avillez can make.

Algorithm

Each letter ([a-z]) in the ingredient list contributes with one character for the soon-to-be-cooked meals. Each portion of our requested meal costs as many of each character as there are in the request string, excluding spaces.

For example, if our requested meal is "bacon" and the ingredients are "banana" and "coconut", the output is 1 because in "bananacoconut" there is only one b, and for each portion of "bacon" we need one "b".

Input

A list of ingredients in any reasonable format, like


a list of strings
a list of lists of characters
a (whatever-you-please)-separated list of ingredients, in a single string


and a requested meal in any reasonable format, like


a string
a list of characters


Output

A non-negative integer representing the amount of meals that can be cooked.

Test cases

A Python reference implementation is available.

['spam', 'spam', 'spam', 'spam', 'bacon', 'eggs', 'eggs', 'bacon', 'spam'], 'beans' -&gt; 2
['bacon', 'bacon', 'bacon', 'bacon', 'bacon'], 'bacon' -&gt; 5
['banana', 'coconut'], 'bacon' -&gt; 1
['acon', 'bcon', 'baon', 'bacn', 'baco'], 'bacon' -&gt; 4
['tomato', 'oregano', 'pizza', 'chocolate'], 'bacon' -&gt; 0
['strawberries', 'figs', 'chocolate', 'sardines'], 'cod fish' -&gt; 1
['these', 'are', 'some', 'random', 'words', 'wow'], 'or' -&gt; 3
['some', 'more', 'delicious', 'ingredients', 'here'], 'bolognese' -&gt; 0
['some', 'delicious', 'ingredients', 'here', 'are', 'bliss'], 'bolognese' -&gt; 1
['some', 'bountiful', 'bagful', 'of', 'ingredients', 'here', 'are', 'bliss'], 'bolognese' -&gt; 1
Python 2, 95 71 70 55 bytes



lambda i,m:min(i.count(c)/m.count(c)for c in m if" "&lt;c)


Try it online!

Input: Ingredients i as a comma-separated string, and a meal m as a string.
Output: Max number of meals that can be made.

How: Divides the frequency of each character in the ingredient by its corresponding character in the meal, then takes the minimum.