atcoder#CODEFESTIVAL2017QUALCD. Yet Another Palindrome Partitioning

Yet Another Palindrome Partitioning

Score : 700700 points

Problem Statement

We have a string ss consisting of lowercase English letters. Snuke is partitioning ss into some number of non-empty substrings. Let the subtrings obtained be s1s_1, s2s_2, ......, sNs_N from left to right. (Here, s=s1+s2+...+sNs = s_1 + s_2 + ... + s_N holds.) Snuke wants to satisfy the following condition:

  • For each ii (1iN1 \leq i \leq N), it is possible to permute the characters in sis_i and obtain a palindrome.

Find the minimum possible value of NN when the partition satisfies the condition.

Constraints

  • 1s2×1051 \leq |s| \leq 2 \times 10^5
  • ss consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

ss

Output

Print the minimum possible value of NN when the partition satisfies the condition.

aabxyyzz
2

The solution is to partition ss as aabxyyzz = aab + xyyzz. Here, aab can be permuted to form a palindrome aba, and xyyzz can be permuted to form a palindrome zyxyz.

byebye
1

byebye can be permuted to form a palindrome byeeyb.

abcdefghijklmnopqrstuvwxyz
26
abcabcxabcx
3

The solution is to partition ss as abcabcxabcx = a + b + cabcxabcx.