cho.sh
Notes
Loading...

Group Word Checker

Time limit

2s

Memory limit

128 MB

Problem

A group word is a word where, for every character in the word, all occurrences of that character form one contiguous block. In other words, once a character stops appearing and another character appears, the first character must not appear again later.

For example, ccazzzzbb is a group word because c, a, z, and b each appear in a single contiguous block. kin is also a group word because every character appears only once. However, aabbbccb is not a group word because b appears in two separated blocks.

Given N words, count how many of them are group words.

Input

The first line contains the number of words N. N is a positive integer no greater than 100.

Each of the next N lines contains one distinct word. Every word consists only of lowercase English letters and has length at most 100.

Output

Print the number of group words on the first line.