#C624. Count Unique Ingredients

    ID: 49978 Type: Default 1000ms 256MiB

Count Unique Ingredients

Count Unique Ingredients

You are given a list of recipes, where each recipe consists of several ingredients. Your task is to count the number of unique ingredients across all recipes.

The unique ingredient count is mathematically represented as $$\left|\bigcup_{i=1}^{R} I_i\right|$$, where (R) is the number of recipes and (I_i) is the set of ingredients for the (i^{th}) recipe.

Use appropriate data structures to solve this problem efficiently.

inputFormat

The input is read from standard input (stdin).

The first line contains an integer (R), representing the number of recipes. For each recipe, the first line contains an integer (M) (the number of ingredients in that recipe), followed by (M) lines each containing a string (the ingredient name).

outputFormat

Print to standard output (stdout) a single integer – the count of unique ingredients across all recipes.## sample

3
3
lettuce
tomato
cheese
2
turkey
lettuce
2
bacon
tomato
5