logo AlgoBeat OnlineJudge
登录 注册

#213539. [COCI 2012/2013 #4] ESEJ

内存限制:32 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Mirko's latest homework assignment is writing an essay. However, he finds writing essays so boring that, after working for two hours, he realized that all he has written are long words consisting entirely of letters and . Having accepted that he will never finish the essay in time, poor Mirko has decided to at least have some fun with it by counting nice words.

Mirko is connecting pairs of identical letters ( with , with ) by drawing arches above the word. A given word is nice if each letter can be connected to exactly one other letter in such a way that no two arches intersect. Help Mirko count how many words are nice.

输入格式

The first line of input contains the positive integer (), the number of words written down by Mirko.

Each of the following lines contains a single word consisting of letters and , with length between and , inclusive. The sum of lengths of all words doesn't exceed .

输出格式

The first and only line of output must contain the number of nice words.

样例

样例输入 1

3
ABAB
AABB
ABBA

样例输出 1

2

样例输入 2

3
AAA
AA
AB

样例输出 2

1

样例输入 3

1
ABBABB

样例输出 3

1