Under construction

Still being built. Things may change

Group Word Checker

Interview

Time limit2sMemory limit128 MB

Summary
Count how many of up to 100 lowercase words have every repeated character forming a single contiguous block.
Level

Easy2 of 10

Topics
String, Implementation
Solved
No attempts yet

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.

Examples6

  1. Example 1

    Input
    3
    happy
    new
    year
    
    Expected output
    3
  2. Example 2

    Input
    4
    aba
    abab
    abcabc
    a
    
    Expected output
    1
    
  3. Example 3

    Input
    5
    ab
    aa
    aca
    ba
    bb
    
    Expected output
    4
    
  4. Example 4

    Input
    2
    yzyzy
    zyzyz
    
    Expected output
    0
    
  5. Example 5

    Input
    1
    z
    
    Expected output
    1
    
  6. Example 6

    Input
    9
    aaa
    aaazbz
    babb
    aazz
    azbz
    aabbaa
    abacc
    aba
    zzaz
    
    Expected output
    2