Read a count n, then n words, then one more word to look up.
Print: how many distinct words there were, how many times the lookup word appeared (0 if never), and the total of all the counts.
For 6, a b a c a b, a:
3
3
6
All three answers are order-independent — never print a map directly, since its order is not guaranteed.