cswork / OAOpen practice workspace

NvidiaOA #6

Palindromic Strings

Estimated MediumJudge-ready

Topics (AI-labelled)GreedyHashing

You may swap any two characters any number of times, including swaps within the same string. Each string keeps its length. Maximize the final number of palindromic strings.

This site uses a standard input/output protocol.

Input

The first line contains N, followed by N lines of non-empty lowercase strings. This site uses 1≤N≤100000 and a total of ≤1000000 characters.

Output

Output a single integer, the answer.

Example 1

Input:

2
ab
cd

Output:

0

Example 2

Input:

2
ab
ba

Output:

2

Example 3

Input:

2
abc
a

Output:

2

Example notes

Example 1: the four characters are all different, so there are no matching pairs; the answer is 0. Example 2: rearrange into aa and bb; the answer is 2. Example 3: rearrange into aba and c; the answer is 2.

Editorial

Loading solution…